make git fetching quite (#3180)

also output repo and branch/commit/tag in one line
This commit is contained in:
Denis Davydov 2017-03-25 01:37:47 +01:00 committed by Todd Gamblin
parent 6461737bba
commit 61d01a71dd

View file

@ -597,25 +597,33 @@ def fetch(self):
tty.msg("Already fetched %s" % self.stage.source_path)
return
args = []
args = ''
if self.commit:
args.append('at commit %s' % self.commit)
args = 'at commit %s' % self.commit
elif self.tag:
args.append('at tag %s' % self.tag)
args = 'at tag %s' % self.tag
elif self.branch:
args.append('on branch %s' % self.branch)
tty.msg("Trying to clone git repository:", self.url, *args)
args = 'on branch %s' % self.branch
tty.msg("Trying to clone git repository: %s %s" % (self.url, args))
if self.commit:
# Need to do a regular clone and check out everything if
# they asked for a particular commit.
self.git('clone', self.url)
if spack.debug:
self.git('clone', self.url)
else:
self.git('clone', '--quiet', self.url)
self.stage.chdir_to_source()
self.git('checkout', self.commit)
if spack.debug:
self.git('checkout', self.commit)
else:
self.git('checkout', '--quiet', self.commit)
else:
# Can be more efficient if not checking out a specific commit.
args = ['clone']
if not spack.debug:
args.append('--quiet')
# If we want a particular branch ask for it.
if self.branch:
@ -652,12 +660,19 @@ def fetch(self):
# pull --tags returns a "special" error code of 1 in
# older versions that we have to ignore.
# see: https://github.com/git/git/commit/19d122b
self.git('pull', '--tags', ignore_errors=1)
self.git('checkout', self.tag)
if spack.debug:
self.git('pull', '--tags', ignore_errors=1)
self.git('checkout', self.tag)
else:
self.git('pull', '--quiet', '--tags', ignore_errors=1)
self.git('checkout', '--quiet', self.tag)
# Init submodules if the user asked for them.
if self.submodules:
self.git('submodule', 'update', '--init')
if spack.debug:
self.git('submodule', 'update', '--init')
else:
self.git('submodule', '--quiet', 'update', '--init')
def archive(self, destination):
super(GitFetchStrategy, self).archive(destination, exclude='.git')
@ -665,8 +680,12 @@ def archive(self, destination):
@_needs_stage
def reset(self):
self.stage.chdir_to_source()
self.git('checkout', '.')
self.git('clean', '-f')
if spack.debug:
self.git('checkout', '.')
self.git('clean', '-f')
else:
self.git('checkout', '--quiet', '.')
self.git('clean', '--quiet', '-f')
def __str__(self):
return "[git] %s" % self.url