mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
repo: add --show-toplevel akin to git
Simple API to make it easy to find the top of the repo client checkout for users. This mirrors the `git rev-parse --show-toplevel` API. Change-Id: I0c3f98def089d0fc9ebcfa50aa3dc02091c1c273 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312909 Reviewed-by: Xin Li <delphij@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
56345c345b
commit
73c43b839f
7
main.py
7
main.py
@ -118,6 +118,10 @@ global_options.add_option('--time',
|
|||||||
global_options.add_option('--version',
|
global_options.add_option('--version',
|
||||||
dest='show_version', action='store_true',
|
dest='show_version', action='store_true',
|
||||||
help='display this version of repo')
|
help='display this version of repo')
|
||||||
|
global_options.add_option('--show-toplevel',
|
||||||
|
action='store_true',
|
||||||
|
help='display the path of the top-level directory of '
|
||||||
|
'the repo client checkout')
|
||||||
global_options.add_option('--event-log',
|
global_options.add_option('--event-log',
|
||||||
dest='event_log', action='store',
|
dest='event_log', action='store',
|
||||||
help='filename of event log to append timeline to')
|
help='filename of event log to append timeline to')
|
||||||
@ -202,6 +206,9 @@ class _Repo(object):
|
|||||||
elif gopts.show_version:
|
elif gopts.show_version:
|
||||||
# Always allow global --version regardless of subcommand validity.
|
# Always allow global --version regardless of subcommand validity.
|
||||||
name = 'version'
|
name = 'version'
|
||||||
|
elif gopts.show_toplevel:
|
||||||
|
print(os.path.dirname(self.repodir))
|
||||||
|
return 0
|
||||||
elif not name:
|
elif not name:
|
||||||
# No subcommand specified, so show the help/subcommand.
|
# No subcommand specified, so show the help/subcommand.
|
||||||
self._PrintHelp(short=True)
|
self._PrintHelp(short=True)
|
||||||
|
@ -34,6 +34,10 @@ time repo command execution
|
|||||||
\fB\-\-version\fR
|
\fB\-\-version\fR
|
||||||
display this version of repo
|
display this version of repo
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-show\-toplevel\fR
|
||||||
|
display the path of the top\-level directory of the
|
||||||
|
repo client checkout
|
||||||
|
.TP
|
||||||
\fB\-\-event\-log\fR=\fI\,EVENT_LOG\/\fR
|
\fB\-\-event\-log\fR=\fI\,EVENT_LOG\/\fR
|
||||||
filename of event log to append timeline to
|
filename of event log to append timeline to
|
||||||
.TP
|
.TP
|
||||||
|
Loading…
Reference in New Issue
Block a user