Tools: Include commits to all branches in weekly report script

Currently the script only includes commits to "main" branches. Much of
people's work is done in branches however, so developers either
customized the script, or they would manually go through own history to
find remaining commits (I asked some).

Even if some people prefer to only list main branch commits, it's much
easier to simply remove some commits than to add missing ones.

To be able to tell which branch a commit was on, this adds a " on
`branch-name`" after the commit hash. Personally I don't find this
optimal, I'd rather group commits under their repository/branch,
proposed separately in #138615.

Pull Request: https://projects.blender.org/blender/blender/pulls/138612
This commit is contained in:
Julian Eisel
2025-05-20 19:07:18 +02:00
parent 416b40af05
commit ec141ba3ff

View File

@@ -136,7 +136,7 @@ def report_personal_weekly_get(
issues_duplicated: list[str] = []
issues_archived: list[str] = []
commits_main: list[str] = []
commits: list[str] = []
user_data: dict[str, Any] = gitea_user_get(username)
@@ -169,7 +169,6 @@ def report_personal_weekly_get(
pulls_reviewed.append(fullname)
elif op_type == "commit_repo":
if (
activity["ref_name"] == "refs/heads/main" and
activity["content"] and
activity["repo"]["name"] != ".profile"
):
@@ -177,13 +176,14 @@ def report_personal_weekly_get(
assert isinstance(content_json, dict)
repo_fullname = activity["repo"]["full_name"]
content_json_commits: list[dict[str, Any]] = content_json["Commits"]
for commits in content_json_commits:
for commit_json in content_json_commits:
# Skip commits that were not made by this user. Using email doesn't seem to
# be possible unfortunately.
if commits["AuthorName"] != user_data["full_name"]:
if commit_json["AuthorName"] != user_data["full_name"]:
continue
title = commits["Message"].split('\n', 1)[0]
title = commit_json["Message"].split('\n', 1)[0]
if title.startswith("Merge branch "):
continue
@@ -191,10 +191,13 @@ def report_personal_weekly_get(
# Substitute occurrences of "#\d+" with "repo#\d+"
title = re.sub(r"#(\d+)", rf"{repo_fullname}#\1", title)
hash_value = commits["Sha1"]
branch_name = activity["ref_name"].removeprefix("refs/heads/")
hash_value = commit_json["Sha1"]
if hash_length > 0:
hash_value = hash_value[:hash_length]
commits_main.append(f"{title} ({repo_fullname}@{hash_value})")
branch_str = f" on `{branch_name}`" if branch_name != "main" else ""
commits.append(f"{title} ({repo_fullname}@{hash_value}{branch_str})")
date_end = date_curr
len_total = len(issues_closed) + len(issues_commented) + len(pulls_commented)
@@ -299,7 +302,7 @@ def report_personal_weekly_get(
# Print commits
print("**Commits:**")
for commit in commits_main:
for commit in commits:
print("*", commit)
print()