File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 6262 "action" : "store_true" ,
6363 "help" : "show output to stdout, no commit, no modified files" ,
6464 },
65+ {
66+ "name" : "--write-message-to-file" ,
67+ "metavar" : "FILE_PATH" ,
68+ "help" : "write message to file before commiting (can be combined with --dry-run)" ,
69+ },
6570 {
6671 "name" : ["-s" , "--signoff" ],
6772 "action" : "store_true" ,
68- "help" : "Sign off the commit" ,
73+ "help" : "sign off the commit" ,
6974 },
7075 ],
7176 },
Original file line number Diff line number Diff line change 1414 NoAnswersError ,
1515 NoCommitBackupError ,
1616 NotAGitProjectError ,
17+ NotAllowed ,
1718 NothingToCommitError ,
1819)
1920from commitizen .git import smart_open
@@ -63,10 +64,18 @@ def prompt_commit_questions(self) -> str:
6364
6465 def __call__ (self ):
6566 dry_run : bool = self .arguments .get ("dry_run" )
67+ write_message_to_file = self .arguments .get ("write_message_to_file" )
6668
6769 if git .is_staging_clean () and not dry_run :
6870 raise NothingToCommitError ("No files added to staging!" )
6971
72+ if write_message_to_file is not None :
73+ if not isinstance (write_message_to_file , str ):
74+ raise NotAllowed (
75+ "Commit message file name is broken.\n "
76+ "Check the flag `--write-message-to-file` in the terminal"
77+ )
78+
7079 retry : bool = self .arguments .get ("retry" )
7180
7281 if retry :
@@ -76,6 +85,10 @@ def __call__(self):
7685
7786 out .info (f"\n { m } \n " )
7887
88+ if write_message_to_file :
89+ with smart_open (write_message_to_file , "w" ) as file :
90+ file .write (m )
91+
7992 if dry_run :
8093 raise DryRunExit ()
8194
You can’t perform that action at this time.
0 commit comments