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

Unified Diff: tests/scm_unittest.py

Issue 549733002: Fix gclient branch ref mangling and allow --force branch switches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: lint Created 6 years, 3 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 | « tests/gclient_scm_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/scm_unittest.py
diff --git a/tests/scm_unittest.py b/tests/scm_unittest.py
index 4e97c73eebea7d4f78ebf987725372bb7ac2ddb0..239740ee4b6d3e7d38af5f06bbcc32d7695392d2 100755
--- a/tests/scm_unittest.py
+++ b/tests/scm_unittest.py
@@ -98,6 +98,7 @@ class GitWrapperTestCase(BaseSCMTestCase):
'IsWorkTreeDirty',
'MatchSvnGlob',
'ParseGitSvnSha1',
+ 'RefToRemoteRef',
'ShortBranchName',
]
# If this test fails, you should add the relevant test.
@@ -122,6 +123,50 @@ class GitWrapperTestCase(BaseSCMTestCase):
'branches/*:refs/remotes/*',
True), 'refs/remotes/bleeding_edge')
+ def testRefToRemoteRefNoRemote(self):
+ refs = {
+ # local ref for upstream branch-head
+ 'refs/remotes/branch-heads/1234': ('refs/remotes/branch-heads/',
+ '1234'),
+ # upstream ref for branch-head
+ 'refs/branch-heads/1234': ('refs/remotes/branch-heads/', '1234'),
+ # could be either local or upstream ref, assumed to refer to
+ # upstream, but probably don't want to encourage refs like this.
+ 'branch-heads/1234': ('refs/remotes/branch-heads/', '1234'),
+ # actively discouraging refs like this, should prepend with 'refs/'
+ 'remotes/branch-heads/1234': None,
+ # might be non-"branch-heads" upstream branches, but can't resolve
+ # without knowing the remote.
+ 'refs/heads/1234': None,
+ 'heads/1234': None,
+ # underspecified, probably intended to refer to a local branch
+ '1234': None,
+ }
+ for k, v in refs.items():
+ r = scm.GIT.RefToRemoteRef(k)
+ self.assertEqual(r, v, msg='%s -> %s, expected %s' % (k, r, v))
+
+ def testRefToRemoteRefWithRemote(self):
+ remote = 'origin'
+ refs = {
+ # This shouldn't be any different from the NoRemote() version.
+ 'refs/branch-heads/1234': ('refs/remotes/branch-heads/', '1234'),
+ # local refs for upstream branch
+ 'refs/remotes/%s/foobar' % remote: ('refs/remotes/%s/' % remote,
+ 'foobar'),
+ '%s/foobar' % remote: ('refs/remotes/%s/' % remote, 'foobar'),
+ # upstream ref for branch
+ 'refs/heads/foobar': ('refs/remotes/%s/' % remote, 'foobar'),
+ # could be either local or upstream ref, assumed to refer to
+ # upstream, but probably don't want to encourage refs like this.
+ 'heads/foobar': ('refs/remotes/%s/' % remote, 'foobar'),
+ # underspecified, probably intended to refer to a local branch
+ 'foobar': None,
+ }
+ for k, v in refs.items():
+ r = scm.GIT.RefToRemoteRef(k, remote)
+ self.assertEqual(r, v, msg='%s -> %s, expected %s' % (k, r, v))
+
class RealGitTest(fake_repos.FakeReposTestBase):
def setUp(self):
« no previous file with comments | « tests/gclient_scm_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698