-
Notifications
You must be signed in to change notification settings - Fork 0
Remove the requirement for jira in opensource #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,6 @@ def get_text_file_content(filename): | |
| data = _get_output(['git', 'show', f':{filename}']) | ||
| return data | ||
|
|
||
|
|
||
| def get_sha(): | ||
| '''Get the commit sha | ||
|
|
||
|
|
@@ -148,6 +147,12 @@ def get_sha(): | |
| ''' | ||
| return _get_output(['git','rev-parse', get_branch()]) | ||
|
|
||
| def get_repo(): | ||
| '''Get the repo name in the format of "owner/repo"''' | ||
| if _is_github_event(): | ||
| return os.environ['GITHUB_REPOSITORY'] | ||
| else: | ||
| return _get_output(['git', 'config', '--get', 'remote.origin.url']).strip().split(':')[-1].rstrip('.git') | ||
|
||
|
|
||
| def get_event(): | ||
| '''Get the git event''' | ||
|
|
@@ -183,7 +188,7 @@ def get_commit_files(): | |
| commands += ['HEAD~..', '--'] | ||
| else: | ||
| commands = ['git', 'diff-index', '--ignore-submodules', 'HEAD', '--cached'] | ||
|
|
||
| output = _get_output(commands) | ||
| result = defaultdict(list) | ||
| for line in output.splitlines(): | ||
|
|
@@ -462,7 +467,7 @@ def test_trim_trailing_whitespace(self): | |
| content = 'first line\nsecond line \nthird line ' | ||
| trimmed_content = 'first line\nsecond line\nthird line' | ||
|
|
||
| name = NamedTemporaryFile().name | ||
| name = NamedTemporaryFile().name | ||
| try: | ||
| Path(name).write_text(content) | ||
| # Trailing whitespace found | ||
|
|
@@ -826,7 +831,7 @@ def check_content(files): | |
| return retval | ||
|
|
||
|
|
||
| def check_commit_msg(message, files): | ||
| def check_commit_msg(message, files, repo): | ||
| '''Check commit message (and file size). | ||
|
|
||
| Abort if file size exceeds hard (github.com) limit. | ||
|
|
@@ -835,6 +840,9 @@ def check_commit_msg(message, files): | |
| does not contain required marker. | ||
|
|
||
| ''' | ||
| if re.match(r'^ccdc-opensource', repo): | ||
| # Do not check for JIRA in opensource repo as we don't want to require external contributors to do this | ||
| return 0 | ||
|
layfield-ccdc marked this conversation as resolved.
Outdated
|
||
| if re.match(r'^Merge ((remote-tracking )?branch|commit) \'.+?\'( of [^\s]+)? into .+', message): | ||
| # Not checking for JIRA or large file in commit message generated by github | ||
| return 0 | ||
|
|
@@ -888,7 +896,7 @@ def _test(input, is_jira=True): | |
| class TestCheckCommitMessage(unittest.TestCase): | ||
| def test_various_strings(self): | ||
| def _test(input, is_good=True): | ||
| rc = check_commit_msg(input, []) | ||
| rc = check_commit_msg(input, [], "dummy/repo") | ||
| self.assertEqual(rc == 0, is_good) | ||
| _test('ABC-1234') | ||
| _test('Some changes for ABC-1234 ticket') | ||
|
|
@@ -933,6 +941,6 @@ def commit_msg_hook(): | |
| commit_message = Path(sys.argv[1]).read_text() | ||
|
|
||
| print(' Check commit message ...') | ||
| retval += check_commit_msg(commit_message, files['M'] + files['A']) | ||
| retval += check_commit_msg(commit_message, files['M'] + files['A'], get_repo()) | ||
|
|
||
| return retval | ||
Uh oh!
There was an error while loading. Please reload this page.