diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-09 15:00:25 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-02-12 20:54:50 +0000 |
commit | 8ddff5c74f533f4f125c957d7bd063452c59f0db (patch) | |
tree | 43122badb2576ba8b81b431bd6da4761879d6cc9 /repo | |
parent | 8409410aa294cad68bf93679726e0a4465e1fe2b (diff) | |
download | git-repo-8ddff5c74f533f4f125c957d7bd063452c59f0db.tar.gz |
repo: add --version support to the launcher
We can get version info when in a checkout, but it'd be helpful
to show that info at all times.
Change-Id: Ieeb44a503c9d7d8c487db4810bdcf3d5f6656c82
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254712
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'repo')
-rwxr-xr-x | repo | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -819,6 +819,7 @@ def _FindRepo(): | |||
819 | 819 | ||
820 | class _Options(object): | 820 | class _Options(object): |
821 | help = False | 821 | help = False |
822 | version = False | ||
822 | 823 | ||
823 | 824 | ||
824 | def _ParseArguments(args): | 825 | def _ParseArguments(args): |
@@ -830,7 +831,8 @@ def _ParseArguments(args): | |||
830 | a = args[i] | 831 | a = args[i] |
831 | if a == '-h' or a == '--help': | 832 | if a == '-h' or a == '--help': |
832 | opt.help = True | 833 | opt.help = True |
833 | 834 | elif a == '--version': | |
835 | opt.version = True | ||
834 | elif not a.startswith('-'): | 836 | elif not a.startswith('-'): |
835 | cmd = a | 837 | cmd = a |
836 | arg = args[i + 1:] | 838 | arg = args[i + 1:] |
@@ -877,6 +879,16 @@ def _Help(args): | |||
877 | sys.exit(1) | 879 | sys.exit(1) |
878 | 880 | ||
879 | 881 | ||
882 | def _Version(): | ||
883 | """Show version information.""" | ||
884 | print('<repo not installed>') | ||
885 | print('repo launcher version %s' % ('.'.join(str(x) for x in VERSION),)) | ||
886 | print(' (from %s)' % (__file__,)) | ||
887 | print('git %s' % (ParseGitVersion().full,)) | ||
888 | print('Python %s' % sys.version) | ||
889 | sys.exit(0) | ||
890 | |||
891 | |||
880 | def _NotInstalled(): | 892 | def _NotInstalled(): |
881 | print('error: repo is not installed. Use "repo init" to install it here.', | 893 | print('error: repo is not installed. Use "repo init" to install it here.', |
882 | file=sys.stderr) | 894 | file=sys.stderr) |
@@ -953,6 +965,8 @@ def main(orig_args): | |||
953 | _Usage() | 965 | _Usage() |
954 | if cmd == 'help': | 966 | if cmd == 'help': |
955 | _Help(args) | 967 | _Help(args) |
968 | if opt.version or cmd == 'version': | ||
969 | _Version() | ||
956 | if not cmd: | 970 | if not cmd: |
957 | _NotInstalled() | 971 | _NotInstalled() |
958 | if cmd == 'init' or cmd == 'gitc-init': | 972 | if cmd == 'init' or cmd == 'gitc-init': |