| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from infra.libs import git2 | 5 from infra.libs import git2 |
| 6 from infra.libs.git2.test import test_util | 6 from infra.libs.git2.test import test_util |
| 7 | 7 |
| 8 | 8 |
| 9 class TestRef(test_util.TestBasis): | 9 class TestRef(test_util.TestBasis): |
| 10 def testComparison(self): | 10 def testComparison(self): |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 def testTo(self): | 39 def testTo(self): |
| 40 r = self.mkRepo() | 40 r = self.mkRepo() |
| 41 A = r['refs/heads/root_A'] | 41 A = r['refs/heads/root_A'] |
| 42 O = r['refs/heads/branch_O'] | 42 O = r['refs/heads/branch_O'] |
| 43 self.assertEqual( | 43 self.assertEqual( |
| 44 list(c.hsh for c in A.to(O)), | 44 list(c.hsh for c in A.to(O)), |
| 45 [self.repo[c] for c in 'BCDLMNO'] | 45 [self.repo[c] for c in 'BCDLMNO'] |
| 46 ) | 46 ) |
| 47 | 47 |
| 48 def testNonFastForward(self): | 48 def testUpdateTo(self): |
| 49 r = self.mkRepo() | |
| 50 O = r['refs/heads/branch_O'] | |
| 51 D = r.get_commit(self.repo['D']) | |
| 52 with self.assertRaises(git2.CalledProcessError): | |
| 53 O.fast_forward_push(D) | |
| 54 self.assertEqual( | |
| 55 self.repo.git('rev-parse', 'branch_O').stdout.strip(), | |
| 56 self.repo['O']) | |
| 57 | |
| 58 def testFastForward(self): | |
| 59 r = self.mkRepo() | 49 r = self.mkRepo() |
| 60 O = r['refs/heads/branch_O'] | 50 O = r['refs/heads/branch_O'] |
| 61 S = r.get_commit(self.repo['S']) | 51 S = r.get_commit(self.repo['S']) |
| 62 self.capture_stdio(O.fast_forward_push, S) | 52 self.capture_stdio(O.update_to, S) |
| 63 self.assertEqual(O.commit.hsh, self.repo['S']) | 53 self.assertEqual(O.commit.hsh, self.repo['S']) |
| 64 self.assertEqual( | |
| 65 self.repo.git('rev-parse', 'branch_O').stdout.strip(), | |
| 66 self.repo['S']) | |
| 67 | |
| 68 | |
| OLD | NEW |