44import sys
55from datetime import datetime
66from math import floor
7+ import argparse
78from subprocess import check_output
8- from typing import NoReturn , Optional
9+ from typing import NoReturn , Optional , Sequence
910
1011
1112def run_command (command : str ) -> str :
@@ -82,9 +83,15 @@ def time_worked_on_commit() -> Optional[str]:
8283 return None
8384
8485
85- def main () -> NoReturn :
86+ def main (argv : Sequence [ str ] | None = None ) -> NoReturn :
8687 # https://confluence.atlassian.com/fisheye/using-smart-commits-960155400.html
8788 # Exit if the branch name does not contain a Jira issue key.
89+ parser = argparse .ArgumentParser ()
90+ parser .add_argument (
91+ '--time-tracking' ,
92+ help = 'Optional time tracking argument' ,
93+ )
94+ args = parser .parse_args (argv )
8895 git_branch_name = current_git_branch_name ()
8996 jira_issue_key = extract_jira_issue_key (git_branch_name )
9097 if not jira_issue_key :
@@ -104,10 +111,11 @@ def main() -> NoReturn:
104111 if "#comment" not in commit_msg and commit_body :
105112 commit_body = f"{ jira_issue_key } #comment { commit_body } "
106113 # 2. Add the time worked to the Work Log in the commit body.
107- work_time = time_worked_on_commit ()
108- if "#time" not in commit_msg and work_time :
109- work_log = f"{ jira_issue_key } #time { work_time } { commit_subject } "
110- commit_body = f"{ commit_body } \n \n { work_log } " if commit_body else work_log
114+ if args .time_tracking :
115+ work_time = time_worked_on_commit ()
116+ if "#time" not in commit_msg and work_time :
117+ work_log = f"{ jira_issue_key } #time { work_time } { commit_subject } "
118+ commit_body = f"{ commit_body } \n \n { work_log } " if commit_body else work_log
111119 # 3. Make sure the subject starts with a Jira issue key.
112120 if not extract_jira_issue_key (commit_subject ):
113121 commit_subject = f"{ jira_issue_key } { commit_subject } "
0 commit comments