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