1mod cli;
2mod relevance;
3pub mod review;
4pub mod types;
5
6pub mod prompt;
7pub mod service;
8
9pub use cli::handle_gen_command;
10use git2::FileMode;
11pub use review::handle_review_command;
12pub use service::IrisCommitService;
13pub use types::{GeneratedMessage, format_commit_message};
14
15use crate::git::CommitResult;
16
17pub fn format_commit_result(result: &CommitResult, message: &str) -> String {
18 let mut output = format!(
19 "[{} {}] {}\n",
20 result.branch,
21 result.commit_hash,
22 message.lines().next().unwrap_or("")
23 );
24
25 output.push_str(&format!(
26 " {} file{} changed, {} insertion{}(+), {} deletion{}(-)\n",
27 result.files_changed,
28 if result.files_changed == 1 { "" } else { "s" },
29 result.insertions,
30 if result.insertions == 1 { "" } else { "s" },
31 result.deletions,
32 if result.deletions == 1 { "" } else { "s" }
33 ));
34
35 for (file, mode) in &result.new_files {
36 output.push_str(&format!(
37 " create mode {} {}\n",
38 format_file_mode(*mode),
39 file
40 ));
41 }
42
43 output
44}
45
46fn format_file_mode(mode: FileMode) -> String {
47 match mode {
48 FileMode::Blob => "100644",
49 FileMode::BlobExecutable => "100755",
50 FileMode::Link => "120000",
51 FileMode::Commit => "160000",
52 FileMode::Tree => "040000",
53 _ => "000000",
54 }
55 .to_string()
56}