Update changelog, plus script to help with updating changelog
This commit is contained in:
parent
058f890c61
commit
8d86645afe
2 changed files with 139 additions and 0 deletions
62
change_log_helper.py
Executable file
62
change_log_helper.py
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
"""Create a list of the MRs into v3 (unless specified) since the last release."""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
import gitlab
|
||||
|
||||
from gitlab.exceptions import GitlabGetError
|
||||
|
||||
PROJECT_ID = 9238334
|
||||
|
||||
|
||||
def main(tag, branch: str = "v3"):
|
||||
"""Create a list of the MRs into a given branch after a tag.
|
||||
|
||||
:param tag: The tag the mrs should be since.
|
||||
:param branch: The Git branch name MRs were merged into.
|
||||
"""
|
||||
try:
|
||||
gl = gitlab.Gitlab()
|
||||
ofm_repo = gl.projects.get(PROJECT_ID)
|
||||
tag_obj = ofm_repo.tags.get(tag)
|
||||
tag_date = tag_obj.commit["committed_date"]
|
||||
# There is no "merged_after option". So get everything updated after
|
||||
relevant_mrs = ofm_repo.mergerequests.list(
|
||||
state="merged",
|
||||
target_branch=branch,
|
||||
order_by="merged_at",
|
||||
updated_after=tag_date,
|
||||
get_all=True,
|
||||
)
|
||||
# Filter for those merged after the tagged commit.
|
||||
for mr in reversed(relevant_mrs):
|
||||
if mr.merged_at > tag_date:
|
||||
print(f"* !{mr.iid} {mr.title}")
|
||||
except GitlabGetError as e:
|
||||
print(f"Failed contact gitlab server.\n{e}")
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"Get Merge requests since a specific tag to help with creating a "
|
||||
"changelog."
|
||||
"The response in printed to the terminal."
|
||||
"Check the start of the list, it may have a couple of extra MRs on the "
|
||||
"same day as the tag."
|
||||
)
|
||||
)
|
||||
parser.add_argument("tag", help="The Git tag to start looking from (required)")
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--branch",
|
||||
default="v3",
|
||||
help="Git branch that requests were merged into (default: v3)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
main(tag=args.tag, branch=args.branch)
|
||||
Loading…
Add table
Add a link
Reference in a new issue