@@ -136,7 +136,6 @@ def get_text_file_content(filename):
136136 data = _get_output (['git' , 'show' , f':{ filename } ' ])
137137 return data
138138
139-
140139def get_sha ():
141140 '''Get the commit sha
142141
@@ -148,6 +147,12 @@ def get_sha():
148147 '''
149148 return _get_output (['git' ,'rev-parse' , get_branch ()])
150149
150+ def get_repo ():
151+ '''Get the repo name in the format of "owner/repo"'''
152+ if _is_github_event ():
153+ return os .environ ['GITHUB_REPOSITORY' ]
154+ else :
155+ return _get_output (['git' , 'config' , '--get' , 'remote.origin.url' ]).strip ().split (':' )[- 1 ].rstrip ('.git' )
151156
152157def get_event ():
153158 '''Get the git event'''
@@ -183,7 +188,7 @@ def get_commit_files():
183188 commands += ['HEAD~..' , '--' ]
184189 else :
185190 commands = ['git' , 'diff-index' , '--ignore-submodules' , 'HEAD' , '--cached' ]
186-
191+
187192 output = _get_output (commands )
188193 result = defaultdict (list )
189194 for line in output .splitlines ():
@@ -462,7 +467,7 @@ def test_trim_trailing_whitespace(self):
462467 content = 'first line\n second line \n third line '
463468 trimmed_content = 'first line\n second line\n third line'
464469
465- name = NamedTemporaryFile ().name
470+ name = NamedTemporaryFile ().name
466471 try :
467472 Path (name ).write_text (content )
468473 # Trailing whitespace found
@@ -826,7 +831,7 @@ def check_content(files):
826831 return retval
827832
828833
829- def check_commit_msg (message , files ):
834+ def check_commit_msg (message , files , repo ):
830835 '''Check commit message (and file size).
831836
832837 Abort if file size exceeds hard (github.com) limit.
@@ -835,6 +840,9 @@ def check_commit_msg(message, files):
835840 does not contain required marker.
836841
837842 '''
843+ if re .match (r'^ccdc-opensource' , repo ):
844+ # Do not check for JIRA in opensource repo as we don't want to require external contributors to do this
845+ return 0
838846 if re .match (r'^Merge ((remote-tracking )?branch|commit) \'.+?\'( of [^\s]+)? into .+' , message ):
839847 # Not checking for JIRA or large file in commit message generated by github
840848 return 0
@@ -933,6 +941,6 @@ def commit_msg_hook():
933941 commit_message = Path (sys .argv [1 ]).read_text ()
934942
935943 print (' Check commit message ...' )
936- retval += check_commit_msg (commit_message , files ['M' ] + files ['A' ])
944+ retval += check_commit_msg (commit_message , files ['M' ] + files ['A' ], get_repo () )
937945
938946 return retval
0 commit comments