git_iris/types/changelog.rs
1//! Changelog types and formatting
2//!
3//! This module provides markdown-based changelog output that lets the LLM drive
4//! the structure while we beautify it for terminal display.
5
6use crate::types::review::render_markdown_for_terminal;
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10/// Markdown-based changelog that lets the LLM determine structure
11///
12/// Follows the Keep a Changelog format (<https://keepachangelog.com>/) but allows
13/// the LLM flexibility in how it organizes and presents changes.
14#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
15pub struct MarkdownChangelog {
16 /// The full markdown content of the changelog entry
17 pub content: String,
18}
19
20impl MarkdownChangelog {
21 /// Render the markdown content with terminal styling
22 pub fn format(&self) -> String {
23 render_markdown_for_terminal(&self.content)
24 }
25
26 /// Get the raw markdown content (for file output, etc.)
27 pub fn raw_content(&self) -> &str {
28 &self.content
29 }
30}
31
32// Re-export the types that are still used by tests and update_changelog_file
33// These are used for test assertions but not for LLM output
34
35/// Enumeration of possible change types for changelog entries (for reference)
36#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, PartialEq, Eq, Hash)]
37pub enum ChangelogType {
38 Added,
39 Changed,
40 Deprecated,
41 Removed,
42 Fixed,
43 Security,
44}
45
46/// Metrics summarizing the changes in a release
47#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, Default)]
48pub struct ChangeMetrics {
49 /// Total number of commits in this release
50 pub total_commits: usize,
51 /// Number of files changed in this release
52 pub files_changed: usize,
53 /// Number of lines inserted in this release
54 pub insertions: usize,
55 /// Number of lines deleted in this release
56 pub deletions: usize,
57 /// Total lines changed in this release
58 pub total_lines_changed: usize,
59}
60
61/// Represents a single change entry in the changelog (for test assertions)
62#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
63pub struct ChangeEntry {
64 /// Description of the change
65 pub description: String,
66 /// List of commit hashes associated with this change
67 pub commit_hashes: Vec<String>,
68 /// List of issue numbers associated with this change
69 pub associated_issues: Vec<String>,
70 /// Pull request number associated with this change, if any
71 pub pull_request: Option<String>,
72}