summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2014-06-14 11:07:01 +0100
committerSam Thursfield <sam@afuera.me.uk>2014-06-14 11:07:01 +0100
commit8033de59fa79f7828ddcc9cb66e73338786dc6c6 (patch)
tree381a805a445928677e25a6a7971909adf46463d6
parent8364ae03e255c8d5e14c8ee45a2d7a0544e289a7 (diff)
downloadmorph-8033de59fa79f7828ddcc9cb66e73338786dc6c6.tar.gz
Second atempt at fixing needless it updates
-rw-r--r--morphlib/app.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 69de43e9..c7fe237d 100644
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -307,7 +307,7 @@ class Morph(cliapp.Application):
'''
absref = None
- def is_fixed_ref(ref):
+ def is_floating_ref(ref):
# This code actually detects if the ref is a valid SHA1. Is there a
# better way to discover if a ref is a named ref or not?
sha1_match = re.match('[A-Fa-f0-9]{40}', ref)
@@ -315,21 +315,18 @@ class Morph(cliapp.Application):
if lrc.has_repo(reponame):
repo = lrc.get_repo(reponame)
- if is_fixed_ref(ref) and repo.ref_exists(ref):
- # We already have the SHA1 in our local copy.
- return ref
-
- if update:
- self.status(msg='Updating cached git repository %(reponame)s for ref %(ref)s',
- reponame=reponame, ref=ref)
- repo.update()
- else:
- # If the ref is a SHA1 that is not available locally, the user
- # will receive an error. If it's a named ref that is available
- # locally that is updated in the remote repo, they will not get
- # the update.
- pass
-
+ if is_floating_ref(ref) or not repo.ref_exists(ref):
+ if update:
+ self.status(
+ msg='Updating cached git repository %(reponame)s for '
+ 'ref %(ref)s', reponame=reponame, ref=ref)
+ repo.update()
+ else:
+ # If the ref is a SHA1 that is not available locally, the
+ # user will receive an error from repo.resolve_ref(). If
+ # it's a named ref that is # available locally that is
+ # updated in the remote repo, they will not get the update.
+ pass
absref, tree = repo.resolve_ref(ref)
elif rrc is not None:
try: