Commit 6895317a authored by hinoka@google.com's avatar hinoka@google.com

Revert of scm.GIT.IsValidRevision: Only return True if the given object is a...

Revert of scm.GIT.IsValidRevision: Only return True if the given object is a commit (https://codereview.chromium.org/329823002/)

Reason for revert:
Speculative revert to see if this is the cause of auto_roll_test.py to fail in build/ presubmit.

Original issue's description:
> scm.GIT.IsValidRevision: Only return True if the given object is a commit
> 
> BUG=383476
> 
> Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=276487

TBR=iannucci@chromium.org,maruel@chromium.org,borenet@google.com
NOTREECHECKS=true
NOTRY=true
BUG=383476

Review URL: https://codereview.chromium.org/329393002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@276493 0039d316-1c4b-4281-b951-d872f2087c98
parent 152cf833
......@@ -491,15 +491,12 @@ 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.
if rev.lower() != sha:
return False
return rev.lower() == sha
if sha_only:
if not sha.startswith(rev.lower()):
return False
return sha.startswith(rev.lower())
return True
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):
......
......@@ -8,7 +8,6 @@
import logging
import os
import sys
import tempfile
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
......@@ -142,17 +141,6 @@ class RealGitTest(fake_repos.FakeReposTestBase):
self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=first_rev))
self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='HEAD'))
# Verify that IsValidRevision returns False for non-commit objects.
tmp = tempfile.NamedTemporaryFile(delete=False)
try:
tmp.write('This is not a commit')
tmp.close()
hashval = scm.GIT.Capture(['hash-object', '-w', tmp.name],
cwd=self.clone_dir)
finally:
os.remove(tmp.name)
self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=hashval))
class RealGitSvnTest(fake_repos.FakeReposTestBase):
def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment