Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Unified Diff: scm.py

Issue 329823002: scm.GIT.IsValidRevision: Only return True if the given object is a commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index eb5c52403c3e2595d14b133a7d0d00e289811d10..d60453dceff9c1e1362d0be94e368e2112619663 100644
--- a/scm.py
+++ b/scm.py
@@ -491,12 +491,15 @@ class GIT(object):
sha = GIT.Capture(['rev-parse', lookup_rev], cwd=cwd).lower()
if lookup_rev != rev:
# Make sure we get the original 40 chars back.
- return rev.lower() == sha
+ if rev.lower() != sha:
+ return False
if sha_only:
- return sha.startswith(rev.lower())
- return True
+ if not sha.startswith(rev.lower()):
+ return False
except subprocess2.CalledProcessError:
return False
+ obj_type = GIT.Capture(['cat-file', '-t', rev], cwd=cwd).strip()
+ return obj_type == 'commit'
@classmethod
def AssertVersion(cls, min_version):
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698