1- /*
2- * Copyright (c) 2025 Hangzhou Guanwaii Technology Co,. Ltd.
1+ /*!
2+ * Copyright (c) 2025 Hangzhou Guanwaii Technology Co., Ltd.
33 *
44 * This source code is licensed under the MIT License,
55 * which is located in the LICENSE file in the source tree's root directory.
66 *
77 * File: main.rs
8- * Author: mingcheng ( mingcheng@apache.org)
8+ * Author: mingcheng < mingcheng@apache.org>
99 * File Created: 2025-03-01 17:17:30
1010 *
11- * Modified By: mingcheng ( mingcheng@apache.org)
12- * Last Modified: 2025-09-26 15:45:37
11+ * Modified By: mingcheng < mingcheng@apache.org>
12+ * Last Modified: 2025-11-07 11:37:33
1313 */
1414
1515use aigitcommit:: built_info:: { PKG_NAME , PKG_VERSION } ;
@@ -26,7 +26,7 @@ use clap::Parser;
2626use std:: error:: Error ;
2727use std:: fs;
2828use std:: io:: Write ;
29- use tracing:: { Level , debug, trace} ;
29+ use tracing:: { Level , debug, error , info , trace} ;
3030
3131use aigitcommit:: utils:: {
3232 OutputFormat , check_env_variables, format_openai_error, get_env, save_to_file, should_signoff,
@@ -143,7 +143,7 @@ async fn main() -> std::result::Result<(), Box<dyn Error>> {
143143 . ok_or ( "Invalid response format: expected title and content separated by double newline" ) ?;
144144
145145 // Detect auto signoff from environment variable or CLI flag
146- let need_signoff = should_signoff ( cli. signoff ) ;
146+ let need_signoff = should_signoff ( & repository , cli. signoff ) ;
147147
148148 let message: GitMessage = GitMessage :: new ( & repository, title, content, need_signoff) ?;
149149
@@ -163,11 +163,11 @@ async fn main() -> std::result::Result<(), Box<dyn Error>> {
163163
164164 // directly commit the changes to the repository if the --commit option is enabled
165165 if cli. commit {
166- trace ! ( "commit option is enabled, will commit the changes to the repository" ) ;
166+ trace ! ( "commit option is enabled, will commit the changes directly to the repository" ) ;
167167
168168 if cli. yes || {
169169 cliclack:: intro ( format ! ( "{PKG_NAME} v{PKG_VERSION}" ) ) ?;
170- cliclack:: confirm ( "Are you sure to commit with those changes ?" ) . interact ( ) ?
170+ cliclack:: confirm ( "Are you sure to commit with generated message below ?" ) . interact ( ) ?
171171 } {
172172 match repository. commit ( & message) {
173173 Ok ( oid) => {
@@ -185,10 +185,16 @@ async fn main() -> std::result::Result<(), Box<dyn Error>> {
185185 // If the --save option is enabled, save the commit message to a file
186186 if !cli. save . is_empty ( ) {
187187 trace ! ( "save option is enabled, will save the commit message to a file" ) ;
188- debug ! ( "the save file path is {:?}" , & cli. save) ;
189188
190- save_to_file ( & cli. save , & result) ?;
191- writeln ! ( std:: io:: stdout( ) , "commit message saved to {}" , cli. save) ?;
189+ // Save the commit message to the specified file
190+ match save_to_file ( & cli. save , & message) {
191+ Ok ( f) => {
192+ info ! ( "commit message saved to file: {:?}" , f) ;
193+ }
194+ Err ( e) => {
195+ error ! ( "failed to save commit message to file: {}" , e) ;
196+ }
197+ }
192198 }
193199
194200 Ok ( ( ) )
0 commit comments