Fix skipping update for git dependency.

'git rev-parse foo' with foo being any 40 character hex string will succeed.
Strip one char to force git to do a proper hash table lookup.

TBR=bauerb@chromium.org
BUG=
TEST=


Review URL: https://chromiumcodereview.appspot.com/10693008

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@144481 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 13 years ago
parent cbd20a408f
commit 8147386697

@ -405,6 +405,12 @@ class GIT(object):
@staticmethod
def IsValidRevision(cwd, rev):
"""Verifies the revision is a proper git revision."""
# 'git rev-parse foo' where foo is *any* 40 character hex string will return
# the string and return code 0. So strip one character to force 'git
# rev-parse' to do a hash table look-up and returns 128 if the hash is not
# present.
if re.match(r'^[0-9a-fA-F]{40}$', rev):
rev = rev[:-1]
try:
GIT.Capture(['rev-parse', rev], cwd=cwd)
return True

Loading…
Cancel
Save