From 9bfdfbe117d16107e07e1c376fec8eb245aab424 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Sep 2019 22:46:45 -0400 Subject: version: add source versions & User-Agents to the output Depending on where/how repo is invoked, the active version might be from a git tree, and it might be different from the .repo/repo.git/ version in the current repo client checkout. Report both if they're different so it's clearer. Lets also include the two different User-Agent's that we set up when talking to networked services. Bug: https://crbug.com/gerrit/11144 Change-Id: I2ebb6e3ac30e374a8406cab3e4438087246a8c57 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239234 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- subcmds/version.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'subcmds/version.py') diff --git a/subcmds/version.py b/subcmds/version.py index 9fb694df..761172b7 100644 --- a/subcmds/version.py +++ b/subcmds/version.py @@ -17,7 +17,7 @@ from __future__ import print_function import sys from command import Command, MirrorSafeCommand -from git_command import git +from git_command import git, RepoSourceVersion, user_agent from git_refs import HEAD class Version(Command, MirrorSafeCommand): @@ -34,12 +34,20 @@ class Version(Command, MirrorSafeCommand): rp = self.manifest.repoProject rem = rp.GetRemote(rp.remote.name) - print('repo version %s' % rp.work_git.describe(HEAD)) + # These might not be the same. Report them both. + src_ver = RepoSourceVersion() + rp_ver = rp.bare_git.describe(HEAD) + print('repo version %s' % rp_ver) print(' (from %s)' % rem.url) if Version.wrapper_path is not None: print('repo launcher version %s' % Version.wrapper_version) print(' (from %s)' % Version.wrapper_path) + if src_ver != rp_ver: + print(' (currently at %s)' % src_ver) + + print('repo User-Agent %s' % user_agent.repo) print('git %s' % git.version_tuple().full) + print('git User-Agent %s' % user_agent.git) print('Python %s' % sys.version) -- cgit v1.2.3-54-g00ecf