Skip to content

Instantly share code, notes, and snippets.

@k3muri84
Created October 25, 2018 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k3muri84/9be0f22e4eac36d30467873528f75626 to your computer and use it in GitHub Desktop.
Save k3muri84/9be0f22e4eac36d30467873528f75626 to your computer and use it in GitHub Desktop.
Find unique jira tickets from git log
#!/usr/bin/env python
# finds jira tickets up until latest tag
# regex part inspired by https://github.com/pbetkier/add-issue-id-hook
import subprocess
import re
project_format = '[A-Z][A-Z]+'
issue_pattern = '{}-[\d]+'.format(project_format)
issues = []
try:
result = subprocess.check_output('git log $(git describe --abbrev=0 --tag)..HEAD --oneline --decorate', shell=True)
for line in result.splitlines():
issue_id_match = re.search(issue_pattern, line)
if issue_id_match:
found_issue_id = issue_id_match.group()
issues.append(found_issue_id)
issues = list(set(issues))
print(issues)
except subprocess.CalledProcessError as e:
print "Calledprocerr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment