mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
repo/init: add --verbose flags
We don't use these for much yet, but init passes it down to the project sync layers which already has support for verbose mode. Change-Id: I651794f1b300be1688eeccf3941ba92c776812b5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256454 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
parent
71928c19a6
commit
edd3d45b35
23
repo
23
repo
@ -265,9 +265,12 @@ def GetParser(gitc_init=False):
|
|||||||
|
|
||||||
# Logging.
|
# Logging.
|
||||||
group = parser.add_option_group('Logging options')
|
group = parser.add_option_group('Logging options')
|
||||||
|
group.add_option('-v', '--verbose',
|
||||||
|
dest='output_mode', action='store_true',
|
||||||
|
help='show all output')
|
||||||
group.add_option('-q', '--quiet',
|
group.add_option('-q', '--quiet',
|
||||||
action='store_true', default=False,
|
dest='output_mode', action='store_false',
|
||||||
help='be quiet')
|
help='only show errors')
|
||||||
|
|
||||||
# Manifest.
|
# Manifest.
|
||||||
group = parser.add_option_group('Manifest options')
|
group = parser.add_option_group('Manifest options')
|
||||||
@ -468,6 +471,8 @@ def _Init(args, gitc_init=False):
|
|||||||
if args:
|
if args:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
opt.quiet = opt.output_mode is False
|
||||||
|
opt.verbose = opt.output_mode is True
|
||||||
|
|
||||||
url = opt.repo_url
|
url = opt.repo_url
|
||||||
if not url:
|
if not url:
|
||||||
@ -527,7 +532,7 @@ def _Init(args, gitc_init=False):
|
|||||||
do_verify = True
|
do_verify = True
|
||||||
|
|
||||||
dst = os.path.abspath(os.path.join(repodir, S_repo))
|
dst = os.path.abspath(os.path.join(repodir, S_repo))
|
||||||
_Clone(url, dst, opt.quiet, opt.clone_bundle)
|
_Clone(url, dst, opt.clone_bundle, opt.quiet, opt.verbose)
|
||||||
|
|
||||||
if do_verify:
|
if do_verify:
|
||||||
rev = _Verify(dst, branch, opt.quiet)
|
rev = _Verify(dst, branch, opt.quiet)
|
||||||
@ -746,7 +751,7 @@ def _InitHttp():
|
|||||||
urllib.request.install_opener(urllib.request.build_opener(*handlers))
|
urllib.request.install_opener(urllib.request.build_opener(*handlers))
|
||||||
|
|
||||||
|
|
||||||
def _Fetch(url, cwd, src, quiet):
|
def _Fetch(url, cwd, src, quiet, verbose):
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Get %s' % url, file=sys.stderr)
|
print('Get %s' % url, file=sys.stderr)
|
||||||
|
|
||||||
@ -762,7 +767,7 @@ def _Fetch(url, cwd, src, quiet):
|
|||||||
run_git(*cmd, stderr=err, cwd=cwd)
|
run_git(*cmd, stderr=err, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
def _DownloadBundle(url, cwd, quiet):
|
def _DownloadBundle(url, cwd, quiet, verbose):
|
||||||
if not url.endswith('/'):
|
if not url.endswith('/'):
|
||||||
url += '/'
|
url += '/'
|
||||||
url += 'clone.bundle'
|
url += 'clone.bundle'
|
||||||
@ -812,12 +817,12 @@ def _DownloadBundle(url, cwd, quiet):
|
|||||||
def _ImportBundle(cwd):
|
def _ImportBundle(cwd):
|
||||||
path = os.path.join(cwd, '.git', 'clone.bundle')
|
path = os.path.join(cwd, '.git', 'clone.bundle')
|
||||||
try:
|
try:
|
||||||
_Fetch(cwd, cwd, path, True)
|
_Fetch(cwd, cwd, path, True, False)
|
||||||
finally:
|
finally:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
|
|
||||||
def _Clone(url, cwd, quiet, clone_bundle):
|
def _Clone(url, cwd, clone_bundle, quiet, verbose):
|
||||||
"""Clones a git repository to a new subdirectory of repodir
|
"""Clones a git repository to a new subdirectory of repodir
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@ -834,9 +839,9 @@ def _Clone(url, cwd, quiet, clone_bundle):
|
|||||||
_SetConfig(cwd,
|
_SetConfig(cwd,
|
||||||
'remote.origin.fetch',
|
'remote.origin.fetch',
|
||||||
'+refs/heads/*:refs/remotes/origin/*')
|
'+refs/heads/*:refs/remotes/origin/*')
|
||||||
if clone_bundle and _DownloadBundle(url, cwd, quiet):
|
if clone_bundle and _DownloadBundle(url, cwd, quiet, verbose):
|
||||||
_ImportBundle(cwd)
|
_ImportBundle(cwd)
|
||||||
_Fetch(url, cwd, 'origin', quiet)
|
_Fetch(url, cwd, 'origin', quiet, verbose)
|
||||||
|
|
||||||
|
|
||||||
def _Verify(cwd, branch, quiet):
|
def _Verify(cwd, branch, quiet):
|
||||||
|
@ -87,9 +87,12 @@ to update the working directory files.
|
|||||||
def _Options(self, p, gitc_init=False):
|
def _Options(self, p, gitc_init=False):
|
||||||
# Logging
|
# Logging
|
||||||
g = p.add_option_group('Logging options')
|
g = p.add_option_group('Logging options')
|
||||||
|
g.add_option('-v', '--verbose',
|
||||||
|
dest='output_mode', action='store_true',
|
||||||
|
help='show all output')
|
||||||
g.add_option('-q', '--quiet',
|
g.add_option('-q', '--quiet',
|
||||||
dest="quiet", action="store_true", default=False,
|
dest='output_mode', action='store_false',
|
||||||
help="be quiet")
|
help='only show errors')
|
||||||
|
|
||||||
# Manifest
|
# Manifest
|
||||||
g = p.add_option_group('Manifest options')
|
g = p.add_option_group('Manifest options')
|
||||||
@ -300,7 +303,7 @@ to update the working directory files.
|
|||||||
if opt.submodules:
|
if opt.submodules:
|
||||||
m.config.SetString('repo.submodules', 'true')
|
m.config.SetString('repo.submodules', 'true')
|
||||||
|
|
||||||
if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet,
|
if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, verbose=opt.verbose,
|
||||||
clone_bundle=opt.clone_bundle,
|
clone_bundle=opt.clone_bundle,
|
||||||
current_branch_only=opt.current_branch_only,
|
current_branch_only=opt.current_branch_only,
|
||||||
tags=opt.tags, submodules=opt.submodules,
|
tags=opt.tags, submodules=opt.submodules,
|
||||||
@ -483,6 +486,9 @@ to update the working directory files.
|
|||||||
% ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),),
|
% ('.'.join(str(x) for x in MIN_GIT_VERSION_SOFT),),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
|
||||||
|
opt.quiet = opt.output_mode is False
|
||||||
|
opt.verbose = opt.output_mode is True
|
||||||
|
|
||||||
if opt.worktree:
|
if opt.worktree:
|
||||||
# Older versions of git supported worktree, but had dangerous gc bugs.
|
# Older versions of git supported worktree, but had dangerous gc bugs.
|
||||||
git_require((2, 15, 0), fail=True, msg='git gc worktree corruption')
|
git_require((2, 15, 0), fail=True, msg='git gc worktree corruption')
|
||||||
|
Loading…
Reference in New Issue
Block a user