Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package git-repo for openSUSE:Factory checked in at 2025-06-23 15:01:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/git-repo (Old) and /work/SRC/openSUSE:Factory/.git-repo.new.7067 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "git-repo" Mon Jun 23 15:01:25 2025 rev:8 rq:1287415 version:2.55.2 Changes: -------- --- /work/SRC/openSUSE:Factory/git-repo/git-repo.changes 2025-05-30 17:21:10.744909762 +0200 +++ /work/SRC/openSUSE:Factory/.git-repo.new.7067/git-repo.changes 2025-06-23 15:01:31.996455282 +0200 @@ -1,0 +2,19 @@ +Fri Jun 13 17:37:23 UTC 2025 - BenoƮt Monin <benoit.mo...@gmx.fr> + +- Update to version 2.55.2: + * info: fix mismatched format args and wrong symbol name + * hooks: add internal check for external hook API + * git_superproject: Replace walrus operator + * upload: Add rev to rootRepo push option + * info: print superproject revision + * subcmds: delete redundant dest= settings + * upload: Add superproject identifier as push option + * manifest: generalize --json as --format=<format> + * run_tests: only allow help2man skipping in CI + * update-manpages: include in unittests + * flake8: Ignore .venv directory + * man: regenerate man pages + * manifest: Remove redundant re-raise of BaseExceptions + * Fallback to full sync when depth enabled fetch of a sha1 fails + +------------------------------------------------------------------- Old: ---- git-repo-2.54.tar.xz New: ---- git-repo-2.55.2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ git-repo.spec ++++++ --- /var/tmp/diff_new_pack.HLzplw/_old 2025-06-23 15:01:32.752486886 +0200 +++ /var/tmp/diff_new_pack.HLzplw/_new 2025-06-23 15:01:32.756487054 +0200 @@ -17,7 +17,7 @@ Name: git-repo -Version: 2.54 +Version: 2.55.2 Release: 0 Summary: The Multiple Git Repository Tool License: Apache-2.0 ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.HLzplw/_old 2025-06-23 15:01:32.796488726 +0200 +++ /var/tmp/diff_new_pack.HLzplw/_new 2025-06-23 15:01:32.800488893 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://gerrit.googlesource.com/git-repo</param> - <param name="changesrevision">97dc5c1bd9527c2abe2183b16a4b7ef037dc34a7</param></service></servicedata> + <param name="changesrevision">b262d0e4619c406a2708856ed312091d21c5bf39</param></service></servicedata> (No newline at EOF) ++++++ git-repo-2.54.tar.xz -> git-repo-2.55.2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/.flake8 new/git-repo-2.55.2/.flake8 --- old/git-repo-2.54/.flake8 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/.flake8 2025-06-10 21:38:23.000000000 +0200 @@ -12,5 +12,6 @@ # E731: do not assign a lambda expression, use a def E731, exclude = + .venv, venv, .tox, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/git_superproject.py new/git-repo-2.55.2/git_superproject.py --- old/git-repo-2.54/git_superproject.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/git_superproject.py 2025-06-10 21:38:23.000000000 +0200 @@ -28,6 +28,7 @@ import sys import time from typing import NamedTuple +import urllib.parse from git_command import git_require from git_command import GitCommand @@ -129,6 +130,30 @@ self._print_messages = value @property + def commit_id(self): + """Returns the commit ID of the superproject checkout.""" + cmd = ["rev-parse", self.revision] + p = GitCommand( + None, # project + cmd, + gitdir=self._work_git, + bare=True, + capture_stdout=True, + capture_stderr=True, + ) + retval = p.Wait() + if retval != 0: + self._LogWarning( + "git rev-parse call failed, command: git {}, " + "return code: {}, stderr: {}", + cmd, + retval, + p.stderr, + ) + return None + return p.stdout + + @property def project_commit_ids(self): """Returns a dictionary of projects and their commit ids.""" return self._project_commit_ids @@ -140,6 +165,26 @@ self._manifest_path if os.path.exists(self._manifest_path) else None ) + @property + def repo_id(self): + """Returns the repo ID for the superproject. + + For example, if the superproject points to: + https://android-review.googlesource.com/platform/superproject/ + Then the repo_id would be: + android/platform/superproject + """ + review_url = self.remote.review + if review_url: + parsed_url = urllib.parse.urlparse(review_url) + netloc = parsed_url.netloc + if netloc: + parts = netloc.split("-review", 1) + host = parts[0] + rev = GitRefs(self._work_git).get("HEAD") + return f"{host}/{self.name}@{rev}" + return None + def _LogMessage(self, fmt, *inputs): """Logs message to stderr and _git_event_log.""" message = f"{self._LogMessagePrefix()} {fmt.format(*inputs)}" @@ -258,7 +303,7 @@ Works only in git repositories. Returns: - data: data returned from 'git ls-tree ...' instead of None. + data: data returned from 'git ls-tree ...'. None on error. """ if not os.path.exists(self._work_git): self._LogWarning( @@ -288,6 +333,7 @@ retval, p.stderr, ) + return None return data def Sync(self, git_event_log): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/hooks.py new/git-repo-2.55.2/hooks.py --- old/git-repo-2.54/hooks.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/hooks.py 2025-06-10 21:38:23.000000000 +0200 @@ -22,6 +22,12 @@ from git_refs import HEAD +# The API we've documented to hook authors. Keep in sync with repo-hooks.md. +_API_ARGS = { + "pre-upload": {"project_list", "worktree_list"}, +} + + class RepoHook: """A RepoHook contains information about a script to run as a hook. @@ -56,6 +62,7 @@ hooks_project, repo_topdir, manifest_url, + bug_url=None, bypass_hooks=False, allow_all_hooks=False, ignore_hooks=False, @@ -75,6 +82,7 @@ run with CWD as this directory. If you have a manifest, this is manifest.topdir. manifest_url: The URL to the manifest git repo. + bug_url: The URL to report issues. bypass_hooks: If True, then 'Do not run the hook'. allow_all_hooks: If True, then 'Run the hook without prompting'. ignore_hooks: If True, then 'Do not abort action if hooks fail'. @@ -85,6 +93,7 @@ self._hooks_project = hooks_project self._repo_topdir = repo_topdir self._manifest_url = manifest_url + self._bug_url = bug_url self._bypass_hooks = bypass_hooks self._allow_all_hooks = allow_all_hooks self._ignore_hooks = ignore_hooks @@ -414,6 +423,20 @@ ignore the result through the option combinations as listed in AddHookOptionGroup(). """ + # Make sure our own callers use the documented API. + exp_kwargs = _API_ARGS.get(self._hook_type, set()) + got_kwargs = set(kwargs.keys()) + if exp_kwargs != got_kwargs: + print( + "repo internal error: " + f"hook '{self._hook_type}' called incorrectly\n" + f" got: {sorted(got_kwargs)}\n" + f" expected: {sorted(exp_kwargs)}\n" + f"Please file a bug: {self._bug_url}", + file=sys.stderr, + ) + return False + # Do not do anything in case bypass_hooks is set, or # no-op if there is no hooks project or if hook is disabled. if ( @@ -472,6 +495,7 @@ "manifest_url": manifest.manifestProject.GetRemote( "origin" ).url, + "bug_url": manifest.contactinfo.bugurl, } ) return cls(*args, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/man/repo-gc.1 new/git-repo-2.55.2/man/repo-gc.1 --- old/git-repo-2.54/man/repo-gc.1 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/man/repo-gc.1 2025-06-10 21:38:23.000000000 +0200 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH REPO "1" "December 2024" "repo gc" "Repo Manual" +.TH REPO "1" "April 2025" "repo gc" "Repo Manual" .SH NAME repo \- repo gc - manual page for repo gc .SH SYNOPSIS @@ -8,7 +8,7 @@ .SH DESCRIPTION Summary .PP -Cleaning up internal repo state. +Cleaning up internal repo and Git state. .SH OPTIONS .TP \fB\-h\fR, \fB\-\-help\fR @@ -19,6 +19,10 @@ .TP \fB\-y\fR, \fB\-\-yes\fR answer yes to all safe prompts +.TP +\fB\-\-repack\fR +repack all projects that use partial clone with +filter=blob:none .SS Logging options: .TP \fB\-v\fR, \fB\-\-verbose\fR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/man/repo-manifest.1 new/git-repo-2.55.2/man/repo-manifest.1 --- old/git-repo-2.54/man/repo-manifest.1 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/man/repo-manifest.1 2025-06-10 21:38:23.000000000 +0200 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH REPO "1" "December 2024" "repo manifest" "Repo Manual" +.TH REPO "1" "April 2025" "repo manifest" "Repo Manual" .SH NAME repo \- repo manifest - manual page for repo manifest .SH SYNOPSIS @@ -30,8 +30,8 @@ (only of use if the branch names for a sha1 manifest are sensitive) .TP -\fB\-\-json\fR -output manifest in JSON format (experimental) +\fB\-\-format\fR=\fI\,FORMAT\/\fR +output format: xml, json (default: xml) .TP \fB\-\-pretty\fR format output for humans to read @@ -78,6 +78,10 @@ attribute is set to indicate the remote ref to push changes to via 'repo upload'. .PP +Multiple output formats are supported via \fB\-\-format\fR. The default output is XML, +and formats are generally "condensed". Use \fB\-\-pretty\fR for more human\-readable +variations. +.PP repo Manifest Format .PP A repo manifest describes the structure of a repo client; that is the @@ -306,25 +310,7 @@ At most one manifest\-server may be specified. The url attribute is used to specify the URL of a manifest server, which is an XML RPC service. .PP -The manifest server should implement the following RPC methods: -.IP -GetApprovedManifest(branch, target) -.PP -Return a manifest in which each project is pegged to a known good revision for -the current branch and target. This is used by repo sync when the \fB\-\-smart\-sync\fR -option is given. -.PP -The target to use is defined by environment variables TARGET_PRODUCT and -TARGET_BUILD_VARIANT. These variables are used to create a string of the form -$TARGET_PRODUCT\-$TARGET_BUILD_VARIANT, e.g. passion\-userdebug. If one of those -variables or both are not present, the program will call GetApprovedManifest -without the target parameter and the manifest server should choose a reasonable -default target. -.IP -GetManifest(tag) -.PP -Return a manifest in which each project is pegged to the revision at the -specified tag. This is used by repo sync when the \fB\-\-smart\-tag\fR option is given. +See the [smart sync documentation](./smart\-sync.md) for more details. .PP Element submanifest .PP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/man/repo.1 new/git-repo-2.55.2/man/repo.1 --- old/git-repo-2.54/man/repo.1 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/man/repo.1 2025-06-10 21:38:23.000000000 +0200 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH REPO "1" "December 2024" "repo" "Repo Manual" +.TH REPO "1" "April 2025" "repo" "Repo Manual" .SH NAME repo \- repository management tool built on top of git .SH SYNOPSIS @@ -80,7 +80,7 @@ Run a shell command in each project .TP gc -Cleaning up internal repo state. +Cleaning up internal repo and Git state. .TP grep Print lines matching a pattern diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/manifest_xml.py new/git-repo-2.55.2/manifest_xml.py --- old/git-repo-2.54/manifest_xml.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/manifest_xml.py 2025-06-10 21:38:23.000000000 +0200 @@ -1328,12 +1328,7 @@ ) # should isolate this to the exact exception, but that's # tricky. actual parsing implementation may vary. - except ( - KeyboardInterrupt, - RuntimeError, - SystemExit, - ManifestParseError, - ): + except (RuntimeError, ManifestParseError): raise except Exception as e: raise ManifestParseError( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/project.py new/git-repo-2.55.2/project.py --- old/git-repo-2.54/project.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/project.py 2025-06-10 21:38:23.000000000 +0200 @@ -2755,6 +2755,14 @@ # field; it doesn't exist, thus abort the optimization attempt # and do a full sync. break + elif depth and is_sha1 and ret == 1: + # In sha1 mode, when depth is enabled, syncing the revision + # from upstream may not work because some servers only allow + # fetching named refs. Fetching a specific sha1 may result + # in an error like 'server does not allow request for + # unadvertised object'. In this case, attempt a full sync + # without depth. + break elif ret < 0: # Git died with a signal, exit immediately. break diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/release/update_manpages.py new/git-repo-2.55.2/release/update_manpages.py --- old/git-repo-2.54/release/update_manpages.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/release/update_manpages.py 2025-06-10 21:38:23.000000000 +0200 @@ -27,9 +27,11 @@ import subprocess import sys import tempfile +from typing import List -TOPDIR = Path(__file__).resolve().parent.parent +THIS_FILE = Path(__file__).resolve() +TOPDIR = THIS_FILE.parent.parent MANDIR = TOPDIR.joinpath("man") # Load repo local modules. @@ -42,9 +44,23 @@ subprocess.run(cmd, **kwargs) -def main(argv): +def get_parser() -> argparse.ArgumentParser: + """Get argument parser.""" parser = argparse.ArgumentParser(description=__doc__) - parser.parse_args(argv) + parser.add_argument( + "-n", + "--check", + "--dry-run", + action="store_const", + const=True, + help="Check if changes are necessary; don't actually change files", + ) + return parser + + +def main(argv: List[str]) -> int: + parser = get_parser() + opts = parser.parse_args(argv) if not shutil.which("help2man"): sys.exit("Please install help2man to continue.") @@ -117,6 +133,7 @@ functools.partial(worker, cwd=tempdir, check=True), cmdlist ) + ret = 0 for tmp_path in MANDIR.glob("*.1.tmp"): path = tmp_path.parent / tmp_path.stem old_data = path.read_text() if path.exists() else "" @@ -133,7 +150,17 @@ ) new_data = re.sub(r'^(\.TH REPO "1" ")([^"]+)', r"\1", data, flags=re.M) if old_data != new_data: - path.write_text(data) + if opts.check: + ret = 1 + print( + f"{THIS_FILE.name}: {path.name}: " + "man page needs regenerating", + file=sys.stderr, + ) + else: + path.write_text(data) + + return ret def replace_regex(data): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/run_tests new/git-repo-2.55.2/run_tests --- old/git-repo-2.54/run_tests 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/run_tests 2025-06-10 21:38:23.000000000 +0200 @@ -17,6 +17,7 @@ import functools import os +import shutil import subprocess import sys from typing import List @@ -101,6 +102,20 @@ ).returncode +def run_update_manpages() -> int: + """Returns the exit code from release/update-manpages.""" + # Allow this to fail on CI, but not local devs. + if is_ci() and not shutil.which("help2man"): + print("update-manpages: help2man not found; skipping test") + return 0 + + return subprocess.run( + [sys.executable, "release/update-manpages", "--check"], + check=False, + cwd=ROOT_DIR, + ).returncode + + def main(argv): """The main entry.""" checks = ( @@ -109,6 +124,7 @@ run_black, run_flake8, run_isort, + run_update_manpages, ) # Run all the tests all the time to get full feedback. Don't exit on the # first error as that makes it more difficult to iterate in the CQ. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/abandon.py new/git-repo-2.55.2/subcmds/abandon.py --- old/git-repo-2.54/subcmds/abandon.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/abandon.py 2025-06-10 21:38:23.000000000 +0200 @@ -48,7 +48,6 @@ def _Options(self, p): p.add_option( "--all", - dest="all", action="store_true", help="delete all branches in all projects", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/diff.py new/git-repo-2.55.2/subcmds/diff.py --- old/git-repo-2.54/subcmds/diff.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/diff.py 2025-06-10 21:38:23.000000000 +0200 @@ -35,7 +35,6 @@ p.add_option( "-u", "--absolute", - dest="absolute", action="store_true", help="paths are relative to the repository root", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/diffmanifests.py new/git-repo-2.55.2/subcmds/diffmanifests.py --- old/git-repo-2.54/subcmds/diffmanifests.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/diffmanifests.py 2025-06-10 21:38:23.000000000 +0200 @@ -67,7 +67,9 @@ def _Options(self, p): p.add_option( - "--raw", dest="raw", action="store_true", help="display raw diff" + "--raw", + action="store_true", + help="display raw diff", ) p.add_option( "--no-color", @@ -78,7 +80,6 @@ ) p.add_option( "--pretty-format", - dest="pretty_format", action="store", metavar="<FORMAT>", help="print the log using a custom git pretty format string", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/download.py new/git-repo-2.55.2/subcmds/download.py --- old/git-repo-2.54/subcmds/download.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/download.py 2025-06-10 21:38:23.000000000 +0200 @@ -60,7 +60,6 @@ p.add_option( "-r", "--revert", - dest="revert", action="store_true", help="revert instead of checkout", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/forall.py new/git-repo-2.55.2/subcmds/forall.py --- old/git-repo-2.54/subcmds/forall.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/forall.py 2025-06-10 21:38:23.000000000 +0200 @@ -133,7 +133,7 @@ @staticmethod def _cmd_option(option, _opt_str, _value, parser): - setattr(parser.values, option.dest, list(parser.rargs)) + setattr(parser.values, option.dest or "command", list(parser.rargs)) while parser.rargs: del parser.rargs[0] @@ -141,7 +141,6 @@ p.add_option( "-r", "--regex", - dest="regex", action="store_true", help="execute the command only on projects matching regex or " "wildcard expression", @@ -149,7 +148,6 @@ p.add_option( "-i", "--inverse-regex", - dest="inverse_regex", action="store_true", help="execute the command only on projects not matching regex or " "wildcard expression", @@ -157,7 +155,6 @@ p.add_option( "-g", "--groups", - dest="groups", help="execute the command only on projects matching the specified " "groups", ) @@ -165,14 +162,12 @@ "-c", "--command", help="command (and arguments) to execute", - dest="command", action="callback", callback=self._cmd_option, ) p.add_option( "-e", "--abort-on-errors", - dest="abort_on_errors", action="store_true", help="abort if a command exits unsuccessfully", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/grep.py new/git-repo-2.55.2/subcmds/grep.py --- old/git-repo-2.54/subcmds/grep.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/grep.py 2025-06-10 21:38:23.000000000 +0200 @@ -120,7 +120,6 @@ g.add_option( "-r", "--revision", - dest="revision", action="append", metavar="TREEish", help="Search TREEish, instead of the work tree", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/info.py new/git-repo-2.55.2/subcmds/info.py --- old/git-repo-2.54/subcmds/info.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/info.py 2025-06-10 21:38:23.000000000 +0200 @@ -43,14 +43,12 @@ p.add_option( "-o", "--overview", - dest="overview", action="store_true", help="show overview of all local commits", ) p.add_option( "-c", "--current-branch", - dest="current_branch", action="store_true", help="consider only checked out branches", ) @@ -104,6 +102,10 @@ self.heading("Manifest groups: ") self.headtext(manifestGroups) self.out.nl() + sp = self.manifest.superproject + srev = sp.commit_id if sp and sp.commit_id else "None" + self.heading("Superproject revision: ") + self.headtext(srev) self.printSeparator() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/list.py new/git-repo-2.55.2/subcmds/list.py --- old/git-repo-2.54/subcmds/list.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/list.py 2025-06-10 21:38:23.000000000 +0200 @@ -40,7 +40,6 @@ p.add_option( "-r", "--regex", - dest="regex", action="store_true", help="filter the project list based on regex or wildcard matching " "of strings", @@ -48,7 +47,6 @@ p.add_option( "-g", "--groups", - dest="groups", help="filter the project list based on the groups the project is " "in", ) @@ -61,21 +59,18 @@ p.add_option( "-n", "--name-only", - dest="name_only", action="store_true", help="display only the name of the repository", ) p.add_option( "-p", "--path-only", - dest="path_only", action="store_true", help="display only the path of the repository", ) p.add_option( "-f", "--fullpath", - dest="fullpath", action="store_true", help="display the full work tree path instead of the relative path", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/manifest.py new/git-repo-2.55.2/subcmds/manifest.py --- old/git-repo-2.54/subcmds/manifest.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/manifest.py 2025-06-10 21:38:23.000000000 +0200 @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import enum import json +import optparse import os import sys @@ -23,6 +25,16 @@ logger = RepoLogger(__file__) +class OutputFormat(enum.Enum): + """Type for the requested output format.""" + + # Canonicalized manifest in XML format. + XML = enum.auto() + + # Canonicalized manifest in JSON format. + JSON = enum.auto() + + class Manifest(PagedCommand): COMMON = False helpSummary = "Manifest inspection utility" @@ -42,6 +54,10 @@ In this case, the 'upstream' attribute is set to the ref we were on when the manifest was generated. The 'dest-branch' attribute is set to indicate the remote ref to push changes to via 'repo upload'. + +Multiple output formats are supported via --format. The default output +is XML, and formats are generally "condensed". Use --pretty for more +human-readable variations. """ @property @@ -86,11 +102,21 @@ "(only of use if the branch names for a sha1 manifest are " "sensitive)", ) + # Replaced with --format=json. Kept for backwards compatibility. + # Can delete in Jun 2026 or later. p.add_option( "--json", - default=False, - action="store_true", - help="output manifest in JSON format (experimental)", + action="store_const", + dest="format", + const=OutputFormat.JSON.name.lower(), + help=optparse.SUPPRESS_HELP, + ) + formats = tuple(x.lower() for x in OutputFormat.__members__.keys()) + p.add_option( + "--format", + default=OutputFormat.XML.name.lower(), + choices=formats, + help=f"output format: {', '.join(formats)} (default: %default)", ) p.add_option( "--pretty", @@ -108,7 +134,6 @@ p.add_option( "-o", "--output-file", - dest="output_file", default="-", help="file to save the manifest to. (Filename prefix for " "multi-tree.)", @@ -121,6 +146,8 @@ if opt.manifest_name: self.manifest.Override(opt.manifest_name, False) + output_format = OutputFormat[opt.format.upper()] + for manifest in self.ManifestList(opt): output_file = opt.output_file if output_file == "-": @@ -135,8 +162,7 @@ manifest.SetUseLocalManifests(not opt.ignore_local_manifests) - if opt.json: - logger.warning("warning: --json is experimental!") + if output_format == OutputFormat.JSON: doc = manifest.ToDict( peg_rev=opt.peg_rev, peg_rev_upstream=opt.peg_rev_upstream, @@ -152,7 +178,7 @@ "separators": (",", ": ") if opt.pretty else (",", ":"), "sort_keys": True, } - fd.write(json.dumps(doc, **json_settings)) + fd.write(json.dumps(doc, **json_settings) + "\n") else: manifest.Save( fd, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/overview.py new/git-repo-2.55.2/subcmds/overview.py --- old/git-repo-2.54/subcmds/overview.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/overview.py 2025-06-10 21:38:23.000000000 +0200 @@ -37,7 +37,6 @@ p.add_option( "-c", "--current-branch", - dest="current_branch", action="store_true", help="consider only checked out branches", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/rebase.py new/git-repo-2.55.2/subcmds/rebase.py --- old/git-repo-2.54/subcmds/rebase.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/rebase.py 2025-06-10 21:38:23.000000000 +0200 @@ -47,21 +47,18 @@ g.add_option( "-i", "--interactive", - dest="interactive", action="store_true", help="interactive rebase (single project only)", ) p.add_option( "--fail-fast", - dest="fail_fast", action="store_true", help="stop rebasing after first error is hit", ) p.add_option( "-f", "--force-rebase", - dest="force_rebase", action="store_true", help="pass --force-rebase to git rebase", ) @@ -74,27 +71,23 @@ ) p.add_option( "--autosquash", - dest="autosquash", action="store_true", help="pass --autosquash to git rebase", ) p.add_option( "--whitespace", - dest="whitespace", action="store", metavar="WS", help="pass --whitespace to git rebase", ) p.add_option( "--auto-stash", - dest="auto_stash", action="store_true", help="stash local modifications before starting", ) p.add_option( "-m", "--onto-manifest", - dest="onto_manifest", action="store_true", help="rebase onto the manifest version instead of upstream " "HEAD (this helps to make sure the local tree stays " diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/selfupdate.py new/git-repo-2.55.2/subcmds/selfupdate.py --- old/git-repo-2.54/subcmds/selfupdate.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/selfupdate.py 2025-06-10 21:38:23.000000000 +0200 @@ -54,7 +54,6 @@ ) g.add_option( "--repo-upgraded", - dest="repo_upgraded", action="store_true", help=optparse.SUPPRESS_HELP, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/stage.py new/git-repo-2.55.2/subcmds/stage.py --- old/git-repo-2.54/subcmds/stage.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/stage.py 2025-06-10 21:38:23.000000000 +0200 @@ -46,7 +46,6 @@ g.add_option( "-i", "--interactive", - dest="interactive", action="store_true", help="use interactive staging", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/start.py new/git-repo-2.55.2/subcmds/start.py --- old/git-repo-2.54/subcmds/start.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/start.py 2025-06-10 21:38:23.000000000 +0200 @@ -51,7 +51,6 @@ def _Options(self, p): p.add_option( "--all", - dest="all", action="store_true", help="begin branch in all projects", ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/status.py new/git-repo-2.55.2/subcmds/status.py --- old/git-repo-2.54/subcmds/status.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/status.py 2025-06-10 21:38:23.000000000 +0200 @@ -82,7 +82,6 @@ p.add_option( "-o", "--orphans", - dest="orphans", action="store_true", help="include objects in working directory outside of repo " "projects", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/sync.py new/git-repo-2.55.2/subcmds/sync.py --- old/git-repo-2.54/subcmds/sync.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/sync.py 2025-06-10 21:38:23.000000000 +0200 @@ -373,19 +373,16 @@ p.add_option( "-f", "--force-broken", - dest="force_broken", action="store_true", help="obsolete option (to be deleted in the future)", ) p.add_option( "--fail-fast", - dest="fail_fast", action="store_true", help="stop syncing after first error is hit", ) p.add_option( "--force-sync", - dest="force_sync", action="store_true", help="overwrite an existing git directory if it needs to " "point to a different object directory. WARNING: this " @@ -393,7 +390,6 @@ ) p.add_option( "--force-checkout", - dest="force_checkout", action="store_true", help="force checkout even if it results in throwing away " "uncommitted modifications. " @@ -401,7 +397,6 @@ ) p.add_option( "--force-remove-dirty", - dest="force_remove_dirty", action="store_true", help="force remove projects with uncommitted modifications if " "projects no longer exist in the manifest. " @@ -409,7 +404,6 @@ ) p.add_option( "--rebase", - dest="rebase", action="store_true", help="rebase local commits regardless of whether they are " "published", @@ -417,7 +411,6 @@ p.add_option( "-l", "--local-only", - dest="local_only", action="store_true", help="only update working tree, don't fetch", ) @@ -433,7 +426,6 @@ p.add_option( "-n", "--network-only", - dest="network_only", action="store_true", help="fetch only, don't update working tree", ) @@ -460,7 +452,6 @@ p.add_option( "-m", "--manifest-name", - dest="manifest_name", help="temporary manifest to use for this sync", metavar="NAME.xml", ) @@ -479,19 +470,16 @@ "-u", "--manifest-server-username", action="store", - dest="manifest_server_username", help="username to authenticate with the manifest server", ) p.add_option( "-p", "--manifest-server-password", action="store", - dest="manifest_server_password", help="password to authenticate with the manifest server", ) p.add_option( "--fetch-submodules", - dest="fetch_submodules", action="store_true", help="fetch submodules from server", ) @@ -515,7 +503,6 @@ ) p.add_option( "--optimized-fetch", - dest="optimized_fetch", action="store_true", help="only fetch projects fixed to sha1 if revision does not exist " "locally", @@ -554,7 +541,6 @@ p.add_option( "-s", "--smart-sync", - dest="smart_sync", action="store_true", help="smart sync using manifest from the latest known good " "build", @@ -562,7 +548,6 @@ p.add_option( "-t", "--smart-tag", - dest="smart_tag", action="store", help="smart sync using manifest from a known tag", ) @@ -577,7 +562,6 @@ ) g.add_option( "--repo-upgraded", - dest="repo_upgraded", action="store_true", help=optparse.SUPPRESS_HELP, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/subcmds/upload.py new/git-repo-2.55.2/subcmds/upload.py --- old/git-repo-2.54/subcmds/upload.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/subcmds/upload.py 2025-06-10 21:38:23.000000000 +0200 @@ -267,7 +267,6 @@ "--cc", type="string", action="append", - dest="cc", help="also send email to these email addresses", ) p.add_option( @@ -281,7 +280,6 @@ p.add_option( "-c", "--current-branch", - dest="current_branch", action="store_true", help="upload current git branch", ) @@ -310,7 +308,6 @@ "-p", "--private", action="store_true", - dest="private", default=False, help="upload as a private change (deprecated; use --wip)", ) @@ -318,7 +315,6 @@ "-w", "--wip", action="store_true", - dest="wip", default=False, help="upload as a work-in-progress change", ) @@ -628,6 +624,13 @@ branch.uploaded = False return + # If using superproject, add the root repo as a push option. + manifest = branch.project.manifest + push_options = list(opt.push_options) + sp = manifest.superproject + if sp and sp.repo_id and manifest.manifestProject.use_superproject: + push_options.append(f"custom-keyed-value=rootRepo:{sp.repo_id}") + branch.UploadForReview( people, dryrun=opt.dryrun, @@ -640,7 +643,7 @@ ready=opt.ready, dest_branch=destination, validate_certs=opt.validate_certs, - push_options=opt.push_options, + push_options=push_options, patchset_description=opt.patchset_description, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/tests/test_subcmds.py new/git-repo-2.55.2/tests/test_subcmds.py --- old/git-repo-2.54/tests/test_subcmds.py 2025-04-10 20:30:42.000000000 +0200 +++ new/git-repo-2.55.2/tests/test_subcmds.py 2025-06-10 21:38:23.000000000 +0200 @@ -89,3 +89,44 @@ msg=f"subcmds/{name}.py: {opt}: only use dashes in " "options, not underscores", ) + + def test_cli_option_dest(self): + """Block redundant dest= arguments.""" + + def _check_dest(opt): + if opt.dest is None or not opt._long_opts: + return + + long = opt._long_opts[0] + assert long.startswith("--") + # This matches optparse's behavior. + implicit_dest = long[2:].replace("-", "_") + if implicit_dest == opt.dest: + bad_opts.append((str(opt), opt.dest)) + + # Hook the option check list. + optparse.Option.CHECK_METHODS.insert(0, _check_dest) + + # Gather all the bad options up front so people can see all bad options + # instead of failing at the first one. + all_bad_opts = {} + for name, cls in subcmds.all_commands.items(): + bad_opts = all_bad_opts[name] = [] + cmd = cls() + # Trigger construction of parser. + cmd.OptionParser + + errmsg = None + for name, bad_opts in sorted(all_bad_opts.items()): + if bad_opts: + if not errmsg: + errmsg = "Omit redundant dest= when defining options.\n" + errmsg += f"\nSubcommand {name} (subcmds/{name}.py):\n" + errmsg += "".join( + f" {opt}: dest='{dest}'\n" for opt, dest in bad_opts + ) + if errmsg: + self.fail(errmsg) + + # Make sure we aren't popping the wrong stuff. + assert optparse.Option.CHECK_METHODS.pop(0) is _check_dest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/git-repo-2.54/tests/test_subcmds_manifest.py new/git-repo-2.55.2/tests/test_subcmds_manifest.py --- old/git-repo-2.54/tests/test_subcmds_manifest.py 1970-01-01 01:00:00.000000000 +0100 +++ new/git-repo-2.55.2/tests/test_subcmds_manifest.py 2025-06-10 21:38:23.000000000 +0200 @@ -0,0 +1,156 @@ +# Copyright (C) 2025 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Unittests for the subcmds/manifest.py module.""" + +import json +from pathlib import Path +from unittest import mock + +import manifest_xml +from subcmds import manifest + + +_EXAMPLE_MANIFEST = """\ +<?xml version="1.0" encoding="UTF-8"?> +<manifest> + <remote name="test-remote" fetch="http://localhost" /> + <default remote="test-remote" revision="refs/heads/main" /> + <project name="repohooks" path="src/repohooks"/> + <repo-hooks in-project="repohooks" enabled-list="a, b"/> +</manifest> +""" + + +def _get_cmd(repodir: Path) -> manifest.Manifest: + """Instantiate a manifest command object to test.""" + manifests_git = repodir / "manifests.git" + manifests_git.mkdir() + (manifests_git / "config").write_text( + """ +[remote "origin"] +\turl = http://localhost/manifest +""" + ) + client = manifest_xml.RepoClient(repodir=str(repodir)) + git_event_log = mock.MagicMock(ErrorEvent=mock.Mock(return_value=None)) + return manifest.Manifest( + repodir=client.repodir, + client=client, + manifest=client.manifest, + outer_client=client, + outer_manifest=client.manifest, + git_event_log=git_event_log, + ) + + +def test_output_format_xml_file(tmp_path): + """Test writing XML to a file.""" + path = tmp_path / "manifest.xml" + path.write_text(_EXAMPLE_MANIFEST) + outpath = tmp_path / "output.xml" + cmd = _get_cmd(tmp_path) + opt, args = cmd.OptionParser.parse_args(["--output-file", str(outpath)]) + cmd.Execute(opt, args) + # Normalize the output a bit as we don't exactly care. + normalize = lambda data: "\n".join( + x.strip() for x in data.splitlines() if x.strip() + ) + assert ( + normalize(outpath.read_text()) + == """<?xml version="1.0" encoding="UTF-8"?> +<manifest> +<remote name="test-remote" fetch="http://localhost"/> +<default remote="test-remote" revision="refs/heads/main"/> +<project name="repohooks" path="src/repohooks"/> +<repo-hooks in-project="repohooks" enabled-list="a b"/> +</manifest>""" + ) + + +def test_output_format_xml_stdout(tmp_path, capsys): + """Test writing XML to stdout.""" + path = tmp_path / "manifest.xml" + path.write_text(_EXAMPLE_MANIFEST) + cmd = _get_cmd(tmp_path) + opt, args = cmd.OptionParser.parse_args(["--format", "xml"]) + cmd.Execute(opt, args) + # Normalize the output a bit as we don't exactly care. + normalize = lambda data: "\n".join( + x.strip() for x in data.splitlines() if x.strip() + ) + stdout = capsys.readouterr().out + assert ( + normalize(stdout) + == """<?xml version="1.0" encoding="UTF-8"?> +<manifest> +<remote name="test-remote" fetch="http://localhost"/> +<default remote="test-remote" revision="refs/heads/main"/> +<project name="repohooks" path="src/repohooks"/> +<repo-hooks in-project="repohooks" enabled-list="a b"/> +</manifest>""" + ) + + +def test_output_format_json(tmp_path, capsys): + """Test writing JSON.""" + path = tmp_path / "manifest.xml" + path.write_text(_EXAMPLE_MANIFEST) + cmd = _get_cmd(tmp_path) + opt, args = cmd.OptionParser.parse_args(["--format", "json"]) + cmd.Execute(opt, args) + obj = json.loads(capsys.readouterr().out) + assert obj == { + "default": {"remote": "test-remote", "revision": "refs/heads/main"}, + "project": [{"name": "repohooks", "path": "src/repohooks"}], + "remote": [{"fetch": "http://localhost", "name": "test-remote"}], + "repo-hooks": {"enabled-list": "a b", "in-project": "repohooks"}, + } + + +def test_output_format_json_pretty(tmp_path, capsys): + """Test writing pretty JSON.""" + path = tmp_path / "manifest.xml" + path.write_text(_EXAMPLE_MANIFEST) + cmd = _get_cmd(tmp_path) + opt, args = cmd.OptionParser.parse_args(["--format", "json", "--pretty"]) + cmd.Execute(opt, args) + stdout = capsys.readouterr().out + assert ( + stdout + == """\ +{ + "default": { + "remote": "test-remote", + "revision": "refs/heads/main" + }, + "project": [ + { + "name": "repohooks", + "path": "src/repohooks" + } + ], + "remote": [ + { + "fetch": "http://localhost", + "name": "test-remote" + } + ], + "repo-hooks": { + "enabled-list": "a b", + "in-project": "repohooks" + } +} +""" + ) ++++++ git-repo.obsinfo ++++++ --- /var/tmp/diff_new_pack.HLzplw/_old 2025-06-23 15:01:32.928494244 +0200 +++ /var/tmp/diff_new_pack.HLzplw/_new 2025-06-23 15:01:32.932494411 +0200 @@ -1,5 +1,5 @@ name: git-repo -version: 2.54 -mtime: 1744309842 -commit: 97dc5c1bd9527c2abe2183b16a4b7ef037dc34a7 +version: 2.55.2 +mtime: 1749584303 +commit: b262d0e4619c406a2708856ed312091d21c5bf39