summaryrefslogtreecommitdiffstats
path: root/scripts/qt/branch_qt.py
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-11-22 10:16:57 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2020-02-24 13:12:33 +0100
commitc591f7431cb569a20b77a26dfda1d3216ad24385 (patch)
tree919f2f06b2e5b8a7c4b003a25dc67948b37d9175 /scripts/qt/branch_qt.py
parent4098117a402db2503a5a0475241ccf93965c686d (diff)
Allow running branch_qt.py on a selection of repositories
When doing merges for example and some repositories are busy, this is convenient to follow up for the remaining repositories that have not yet been processed. Change-Id: Ia01656177afaa43580304cd4beb467bc01ff0ff6 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'scripts/qt/branch_qt.py')
-rwxr-xr-xscripts/qt/branch_qt.py47
1 files changed, 30 insertions, 17 deletions
diff --git a/scripts/qt/branch_qt.py b/scripts/qt/branch_qt.py
index 44899613..01e54e57 100755
--- a/scripts/qt/branch_qt.py
+++ b/scripts/qt/branch_qt.py
@@ -89,12 +89,13 @@ def get_repo_name(repo: git.Repo) -> str:
return os.path.basename(repo.working_dir)
class QtBranching:
- def __init__(self, mode: Mode, fromBranch: str, toBranch: str, pretend: bool, skip_hooks: bool) -> None:
+ def __init__(self, mode: Mode, fromBranch: str, toBranch: str, pretend: bool, skip_hooks: bool, repos: typing.Optional[typing.List[str]]) -> None:
self.mode = mode
self.fromBranch = fromBranch
self.toBranch = toBranch
self.pretend = pretend
self.skip_hooks = skip_hooks
+ self.repos = repos
log.info(f"{self.mode.name} from '{self.fromBranch}' to '{self.toBranch}'")
def subprocess_or_pretend(self, *args: typing.Any, **kwargs: typing.Any) -> None:
@@ -107,6 +108,23 @@ class QtBranching:
self.sanity_check()
self.init_repository()
+ if self.repos:
+ # a list of custom repositories to process, instead of the default (everything)
+ for repo_path in self.repos:
+ self.process_repository(repo_path)
+ else:
+ self.process_qt5_repositories()
+ # Additional repositories that are not part of qt5.git:
+ for repo_path in extra_repositories:
+ self.process_repository(repo_path)
+
+ if self.mode == Mode['branch']:
+ log.info("Adjusting submodule branches in .gitmodules")
+ self.subprocess_or_pretend(['git', 'commit', '-m', 'Adjust submodule branches', '.gitmodules'])
+ # update the new and staging branch
+ self.subprocess_or_pretend(['git', 'push', 'gerrit', f'HEAD:refs/heads/{self.toBranch}', f'HEAD:refs/staging/{self.toBranch}'])
+
+ def process_qt5_repos(self) -> None:
repo = git.Repo('.')
for submodule in repo.submodules:
if submodule.name in skipped_submodules:
@@ -118,21 +136,14 @@ class QtBranching:
else:
log.info(f"SKIPPING {submodule.name}")
- # Additional repositories that are not part of qt5.git:
- for repo_path in extra_repositories:
- log.info(f"Extra repository: '{repo_path}'")
- assert '/' in repo_path, f"Extra repository must be specified with namespace {repo_path}"
- repo = self.clone_extra_repo(path=repo_path, branch=self.fromBranch)
- if repo:
- self.handle_module(repo)
- else:
- log.warning(f"Could not handle '{repo_path}'.")
-
- if self.mode == Mode['branch']:
- log.info("Adjusting submodule branches in .gitmodules")
- self.subprocess_or_pretend(['git', 'commit', '-m', 'Adjust submodule branches', '.gitmodules'])
- # update the new and staging branch
- self.subprocess_or_pretend(['git', 'push', 'gerrit', f'HEAD:refs/heads/{self.toBranch}', f'HEAD:refs/staging/{self.toBranch}'])
+ def process_repository(self, repo_path: str) -> None:
+ log.info(f"Extra repository: '{repo_path}'")
+ assert '/' in repo_path, f"Extra repository must be specified with namespace {repo_path}"
+ repo = self.clone_extra_repo(path=repo_path, branch=self.fromBranch)
+ if repo:
+ self.handle_module(repo)
+ else:
+ log.warning(f"Could not handle '{repo_path}'.")
def handle_module(self, repo: git.Repo) -> None:
oldpath = os.path.abspath(os.curdir)
@@ -375,6 +386,8 @@ def parse_args() -> argparse.Namespace:
help="Make the changes to the repositories, but do not push to Gerrit.")
parser.add_argument("--skip-hooks", action="store_true",
help="Do not run git commit hooks.")
+ parser.add_argument("--repos", nargs="*",
+ help="Optional list of repositories (instead of processing all repositories).")
return parser.parse_args(sys.argv[1:])
@@ -396,7 +409,7 @@ if __name__ == "__main__":
if not args.pretend:
gerrit_add_pushmaster()
- branching = QtBranching(mode=Mode[args.mode], fromBranch=args.fromBranch, toBranch=args.toBranch, pretend=args.pretend, skip_hooks=args.skip_hooks)
+ branching = QtBranching(mode=Mode[args.mode], fromBranch=args.fromBranch, toBranch=args.toBranch, pretend=args.pretend, skip_hooks=args.skip_hooks, repos=args.repos)
branching.run()
finally:
if not args.pretend: