aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-05-03 16:55:17 +0200
committerCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2021-05-12 13:43:16 +0200
commit7118ab7a34b1c3c6a9b0b1d29e0a9d2011a2d887 (patch)
treea48d0ae171053460afbf6190db088fec3b7241cd
parentcc011c8980cc4ce02e3d9cceb74ee028c204214e (diff)
create_changelog: add option to exclude pick-to
This enables the option '-e/--exclude' to skip all the sha1 related to commits that have been already picked to another previous version. The motivation comes to be able to generate the changelog for 6.1, which comes from the dev branch that already have many patches that are already cherry picked to previous releases. The logic is the following: - A: Get sha1 from the latest previous non-minor release to the new minor-release: origin/6.0.3 and origin/6.1 (created) - B: Get all the commits from there that have a 'Pick-to' entry - Use the remaining sha1 from: A - B Change-Id: I1e1fb5c225c13180dc15ea3e92ce4a641f6455f2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tools/create_changelog.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/create_changelog.py b/tools/create_changelog.py
index 539df3fe2..71a9c30b1 100644
--- a/tools/create_changelog.py
+++ b/tools/create_changelog.py
@@ -97,6 +97,12 @@ def parse_options() -> Namespace:
help="Release type: bug-fix, minor, or major",
default="bug-fix")
+ options.add_argument("-e",
+ "--exclude",
+ action="store_true",
+ help="Exclude commits with a 'Pick-to' line",
+ default=False)
+
args = options.parse_args()
if args.type not in ("bug-fix", "minor", "major"):
print("Error:"
@@ -151,7 +157,24 @@ def git_get_sha1s(versions: List[str], pattern: str):
out_sha1, err = Popen(command, stdout=PIPE, shell=True).communicate()
if err:
print(err, file=sys.stderr)
- return [s.decode("utf-8") for s in out_sha1.splitlines()]
+
+ pick_to_sha1 = []
+
+ if exclude_pick_to:
+ # if '-e', we exclude all the 'Pick-to' changes
+ command = "git rev-list --reverse --grep '^Pick-to:'"
+ command += " {}..{}".format(versions[0], versions[1])
+ command += " | git cat-file --batch"
+ command += " | grep -o -E \"^[0-9a-f]{40} commit\""
+ command += " | awk '{print $1}'"
+ print("{}: {}".format(git_command.__name__, command), file=sys.stderr)
+ out_e_sha1, err = Popen(command, stdout=PIPE, shell=True).communicate()
+ if err:
+ print(err, file=sys.stderr)
+ pick_to_sha1 = out_e_sha1.splitlines()
+
+
+ return [s.decode("utf-8") for s in out_sha1.splitlines() if s not in pick_to_sha1]
def git_command(versions: List[str], pattern: str):
@@ -243,6 +266,8 @@ if __name__ == "__main__":
pyside6_changelogs: List[str] = []
shiboken6_changelogs: List[str] = []
+ exclude_pick_to = args.exclude
+
# Getting commits information
directory = args.directory if args.directory else "."
versions = args.versions.split("..")