martin-g commented on code in PR #1768:
URL:
https://github.com/apache/datafusion-ballista/pull/1768#discussion_r3300833077
##########
dev/release/generate-changelog.py:
##########
@@ -75,26 +75,83 @@ def generate_changelog(repo, repo_name, tag1, tag2):
cc_breaking = parts_tuple[2] == '!'
labels = [label.name for label in pull.labels]
- #print(pull.number, labels, parts, file=sys.stderr)
if 'api change' in labels or cc_breaking:
breaking.append((pull, commit))
- elif 'bug' in labels or cc_type == 'fix':
- bugs.append((pull, commit))
elif 'performance' in labels or cc_type == 'perf':
performance.append((pull, commit))
+ elif 'bug' in labels or cc_type == 'fix':
+ bugs.append((pull, commit))
elif 'enhancement' in labels or cc_type == 'feat':
enhancements.append((pull, commit))
- elif 'documentation' in labels or cc_type == 'docs':
+ elif 'documentation' in labels or cc_type == 'docs' or cc_type ==
'doc':
docs.append((pull, commit))
+ else:
+ other.append((pull, commit))
# produce the changelog content
print("Generating changelog content", file=sys.stderr)
+
+ # ASF header
+ print("""<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->\n""")
+
+ print(f"# Apache DataFusion Ballista {version} Changelog\n")
+
+ # get the number of commits
+ commit_count = subprocess.check_output(f"git log --pretty=oneline
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
+
+ # get number of contributors
+ contributor_count = subprocess.check_output(f"git shortlog -sn
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
Review Comment:
```suggestion
shortlog_output = subprocess.check_output(["git", "shortlog", "-sn",
f"{tag1}..{tag2}"], text=True)
contributor_count = len(shortlog_output.strip().splitlines())
```
##########
dev/release/generate-changelog.py:
##########
@@ -75,26 +75,83 @@ def generate_changelog(repo, repo_name, tag1, tag2):
cc_breaking = parts_tuple[2] == '!'
labels = [label.name for label in pull.labels]
- #print(pull.number, labels, parts, file=sys.stderr)
if 'api change' in labels or cc_breaking:
breaking.append((pull, commit))
- elif 'bug' in labels or cc_type == 'fix':
- bugs.append((pull, commit))
elif 'performance' in labels or cc_type == 'perf':
performance.append((pull, commit))
+ elif 'bug' in labels or cc_type == 'fix':
+ bugs.append((pull, commit))
elif 'enhancement' in labels or cc_type == 'feat':
enhancements.append((pull, commit))
- elif 'documentation' in labels or cc_type == 'docs':
+ elif 'documentation' in labels or cc_type == 'docs' or cc_type ==
'doc':
docs.append((pull, commit))
+ else:
+ other.append((pull, commit))
# produce the changelog content
print("Generating changelog content", file=sys.stderr)
+
+ # ASF header
+ print("""<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->\n""")
+
+ print(f"# Apache DataFusion Ballista {version} Changelog\n")
+
+ # get the number of commits
+ commit_count = subprocess.check_output(f"git log --pretty=oneline
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
+
+ # get number of contributors
+ contributor_count = subprocess.check_output(f"git shortlog -sn
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
+
+ print(f"This release consists of {commit_count} commits from
{contributor_count} contributors. "
+ f"See credits at the end of this changelog for more information.\n")
+
print_pulls(repo_name, "Breaking changes", breaking)
+ print_pulls(repo_name, "Fixed bugs", bugs)
print_pulls(repo_name, "Performance related", performance)
print_pulls(repo_name, "Implemented enhancements", enhancements)
- print_pulls(repo_name, "Fixed bugs", bugs)
print_pulls(repo_name, "Documentation updates", docs)
- print_pulls(repo_name, "Merged pull requests", all_pulls)
+ print_pulls(repo_name, "Other", other)
+
+ # show code contributions
+ credits = subprocess.check_output(f"git shortlog -sn {tag1}..{tag2}",
shell=True, text=True).rstrip()
Review Comment:
```suggestion
credits = shortlog_output.rstrip()
```
##########
dev/release/generate-changelog.py:
##########
@@ -75,26 +75,83 @@ def generate_changelog(repo, repo_name, tag1, tag2):
cc_breaking = parts_tuple[2] == '!'
labels = [label.name for label in pull.labels]
- #print(pull.number, labels, parts, file=sys.stderr)
if 'api change' in labels or cc_breaking:
breaking.append((pull, commit))
- elif 'bug' in labels or cc_type == 'fix':
- bugs.append((pull, commit))
elif 'performance' in labels or cc_type == 'perf':
performance.append((pull, commit))
+ elif 'bug' in labels or cc_type == 'fix':
+ bugs.append((pull, commit))
elif 'enhancement' in labels or cc_type == 'feat':
enhancements.append((pull, commit))
- elif 'documentation' in labels or cc_type == 'docs':
+ elif 'documentation' in labels or cc_type == 'docs' or cc_type ==
'doc':
docs.append((pull, commit))
+ else:
+ other.append((pull, commit))
# produce the changelog content
print("Generating changelog content", file=sys.stderr)
+
+ # ASF header
+ print("""<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->\n""")
+
+ print(f"# Apache DataFusion Ballista {version} Changelog\n")
+
+ # get the number of commits
+ commit_count = subprocess.check_output(f"git log --pretty=oneline
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
+
+ # get number of contributors
+ contributor_count = subprocess.check_output(f"git shortlog -sn
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
+
+ print(f"This release consists of {commit_count} commits from
{contributor_count} contributors. "
+ f"See credits at the end of this changelog for more information.\n")
+
print_pulls(repo_name, "Breaking changes", breaking)
+ print_pulls(repo_name, "Fixed bugs", bugs)
print_pulls(repo_name, "Performance related", performance)
print_pulls(repo_name, "Implemented enhancements", enhancements)
- print_pulls(repo_name, "Fixed bugs", bugs)
print_pulls(repo_name, "Documentation updates", docs)
- print_pulls(repo_name, "Merged pull requests", all_pulls)
+ print_pulls(repo_name, "Other", other)
+
+ # show code contributions
+ credits = subprocess.check_output(f"git shortlog -sn {tag1}..{tag2}",
shell=True, text=True).rstrip()
+
+ print("## Credits\n")
+ print("Thank you to everyone who contributed to this release. Here is a
breakdown of commits (PRs merged) "
+ "per contributor.\n")
+ print("```")
+ print(credits)
+ print("```\n")
+
+ print("Thank you also to everyone who contributed in other ways such as
filing issues, reviewing "
+ "PRs, and providing feedback on this release.\n")
+
+def resolve_ref(ref):
+ """Resolve a git ref (e.g. HEAD, branch name) to a full commit SHA."""
+ try:
+ return subprocess.check_output(
+ ["git", "rev-parse", ref], text=True
+ ).strip()
+ except subprocess.CalledProcessError:
+ # If it can't be resolved locally, return as-is (e.g. a tag name
+ # that the GitHub API can resolve)
+ return ref
Review Comment:
```suggestion
# If it can't be resolved locally, return as-is (e.g. a remote tag).
# The GitHub API will attempt to resolve it.
print(f"Note: Could not resolve '{ref}' locally; passing to GitHub
API as-is", file=sys.stderr)
return ref
```
##########
dev/release/generate-changelog.py:
##########
@@ -75,26 +75,83 @@ def generate_changelog(repo, repo_name, tag1, tag2):
cc_breaking = parts_tuple[2] == '!'
labels = [label.name for label in pull.labels]
- #print(pull.number, labels, parts, file=sys.stderr)
if 'api change' in labels or cc_breaking:
breaking.append((pull, commit))
- elif 'bug' in labels or cc_type == 'fix':
- bugs.append((pull, commit))
elif 'performance' in labels or cc_type == 'perf':
performance.append((pull, commit))
+ elif 'bug' in labels or cc_type == 'fix':
+ bugs.append((pull, commit))
elif 'enhancement' in labels or cc_type == 'feat':
enhancements.append((pull, commit))
- elif 'documentation' in labels or cc_type == 'docs':
+ elif 'documentation' in labels or cc_type == 'docs' or cc_type ==
'doc':
docs.append((pull, commit))
+ else:
+ other.append((pull, commit))
# produce the changelog content
print("Generating changelog content", file=sys.stderr)
+
+ # ASF header
+ print("""<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->\n""")
+
+ print(f"# Apache DataFusion Ballista {version} Changelog\n")
+
+ # get the number of commits
+ commit_count = subprocess.check_output(f"git log --pretty=oneline
{tag1}..{tag2} | wc -l", shell=True, text=True).strip()
Review Comment:
```suggestion
commit_count = subprocess.check_output(["git", "rev-list", "--count",
f"{tag1}..{tag2}"], text=True).strip()
```
`git rev-list --count` is more efficient since there is no need to pipe to
wc -l (also more Windows-friendly).
Also, using an array + string format only for the tags + shell=False
prevents command injection.
##########
dev/release/generate-changelog.py:
##########
Review Comment:
```suggestion
parts = re.findall(r'^([a-zA-Z]+)(\([a-zA-Z0-9_-]+\))?(!)?:',
pull.title)
```
Conventional commits allow upper-case too
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]