diff options
author | Daniel Smith <daniel.smith@qt.io> | 2022-08-16 10:49:08 +0200 |
---|---|---|
committer | Daniel Smith <daniel.smith@qt.io> | 2022-09-12 10:59:41 +0200 |
commit | a2fa85b07f8e06ed777c13d48a2cc6fe1ea40055 (patch) | |
tree | d7740d922ac887061f9a5e870b4a2f5c9e35e2d8 | |
parent | 6c1acde2b4ba99ea158b88a038585a5cc6df7a5a (diff) |
Add change ID creation directly to the commit message
If hooks are skipped, but --direct is not used, a change-id
is still needed in the commit message. Since Qt repos do not
allow generation of the change ID at upload time, generate
a gerrit-compatible ID and attach it to the commit message
during commit.
Change-Id: I71089dfda43ea310318219677cbb55523a13f987
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
-rwxr-xr-x | scripts/qt/branch_qt.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/qt/branch_qt.py b/scripts/qt/branch_qt.py index a7826900..ebed6b1f 100755 --- a/scripts/qt/branch_qt.py +++ b/scripts/qt/branch_qt.py @@ -15,6 +15,7 @@ import re import requests import subprocess import sys +import uuid from typing import List, Iterable, Any, Dict, Union from configparser import ConfigParser @@ -138,6 +139,11 @@ def versionCompare(version1: str, version2: str) -> int: return cmp(normalize(version1), normalize(version2)) +def make_change_id() -> str: + """Create a Change-Id that Gerrit will accept""" + return "I" + uuid.uuid4().hex + uuid.uuid4().hex[:8] + + class QtBranching: def __init__(self, mode: Mode, **kws) -> None: self.mode = mode @@ -440,7 +446,11 @@ class QtBranching: if not repo.is_dirty(): log.warning(f"nothing to do for {repo_name}, is the version bump already done?") return - repo.index.commit(f"Bump version to {self.toBranch}", skip_hooks=self.skip_hooks) + change_id_str = "" + if not self.direct: + change_id_str = f"\n\nChange-Id: {make_change_id()}" + repo.index.commit(f"Bump version to {self.toBranch}{change_id_str}", + skip_hooks=self.skip_hooks) self.push(repo_name, from_version) def version_bump_repo(self, repo: git.Repo) -> None: |