Skip to main content

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    #[must_use]
23    pub fn format(&self) -> String {
24        render_markdown_for_terminal(&self.content)
25    }
26
27    /// Get the raw markdown content (for file output, etc.)
28    #[must_use]
29    pub fn raw_content(&self) -> &str {
30        &self.content
31    }
32}
33
34// Re-export the types that are still used by tests and update_changelog_file
35// These are used for test assertions but not for LLM output
36
37/// Enumeration of possible change types for changelog entries (for reference)
38#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, PartialEq, Eq, Hash)]
39pub enum ChangelogType {
40    Added,
41    Changed,
42    Deprecated,
43    Removed,
44    Fixed,
45    Security,
46}
47
48/// Metrics summarizing the changes in a release
49#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug, Default)]
50pub struct ChangeMetrics {
51    /// Total number of commits in this release
52    pub total_commits: usize,
53    /// Number of files changed in this release
54    pub files_changed: usize,
55    /// Number of lines inserted in this release
56    pub insertions: usize,
57    /// Number of lines deleted in this release
58    pub deletions: usize,
59    /// Total lines changed in this release
60    pub total_lines_changed: usize,
61}
62
63/// Represents a single change entry in the changelog (for test assertions)
64#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
65pub struct ChangeEntry {
66    /// Description of the change
67    pub description: String,
68    /// List of commit hashes associated with this change
69    pub commit_hashes: Vec<String>,
70    /// List of issue numbers associated with this change
71    pub associated_issues: Vec<String>,
72    /// Pull request number associated with this change, if any
73    pub pull_request: Option<String>,
74}