Skip to content
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

Update generate_changelog script to remove PR IDs #6071

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,45 +43,52 @@ def checkKeyWords(list_keywords, commit):
return True
return False

# Given a commit message from a merged Pull Request, remove the PR ID.
# Example: "My first commit (#1)" -> "My first commit"
def remove_pull_request_id(commit_message):
regexp = "\(#\d+\)"
return re.sub(regexp, '', commit_message).strip()

def generateChangeLog(release, date, origin):
git_diff=subprocess.Popen(['git', 'log', '--no-merges', '--oneline', "--pretty=split:'%s'", origin+'/master...HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout,stderr = git_diff.communicate()
clean_sdout = str(stdout).replace('b\"', '').replace('\n', '').replace('\\n','').replace("'", '').replace('\"','')
commit_array=clean_sdout.split('split:')
commit_array.pop(0)
git_log_command = ["git", "log", "--no-merges", "--oneline", "--pretty='%s'", "{}/master...HEAD".format(origin)]

commits = subprocess.check_output(git_log_command, subprocess.STDOUT).decode('utf-8').split('\n')

# Strip the first and last characters of each line, which are single quotes.
commits = [c[1:-1] for c in commits]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is much cleaner


breaking=[]
added=[]
changed=[]
fixed=[]
jql_query=[]

for i,commit in enumerate(commit_array):
jira_key_regex=re.match('(''|\s)M3(-|\s)\d{1,5}(-|\s|:)', commit)
if( not (jira_key_regex is None) ):
for commit in commits:
commit = remove_pull_request_id(commit)

jira_key_regex=re.match('M3-\d{4}', commit)
if (jira_key_regex is not None):
jira_key=jira_key_regex.group(0)
jql_query.append(jira_key)
commit_array[i]=commit.lstrip(jira_key)
commit.lstrip(jira_key)

if(checkKeyWords(TEST_KEYWORDS, commit.lower())):
NOT_INCLUDED_IN_LOG.append(commit_array[i])
NOT_INCLUDED_IN_LOG.append(commit)
continue

if(checkKeyWords(BREAKING_KEYWORDS, commit.lower())):
breaking.append(commit_array[i])
breaking.append(commit)
continue

if(checkKeyWords(CHANGED_KEYWORDS, commit.lower())):
changed.append(commit_array[i])
changed.append(commit)
continue

if(checkKeyWords(FIXED_KEYWORDS, commit.lower())):
fixed.append(commit_array[i])
fixed.append(commit)
continue

added.append(commit_array[i])
added.append(commit)


generateJQLQuery(jql_query)
Expand Down