def test_update(self): first = repo.make_one_commit('file.txt', ORIGINAL, 'original') self.assertEqual(first, '28da9aa') second = repo.make_one_commit('file.txt', DELTA3, 'master!') self.assertEqual(second, 'd1b2fc8') GIT.push('--set-upstream', 'upstream', 'master') GIT.reset('--hard', 'HEAD~') GIT.push('--set-upstream', 'origin', 'master') # No conflicts GIT.new('one') repo.make_commit('one') GIT.push() # Resolvable conflict GIT.new('two') repo.make_one_commit('file.txt', DELTA1, 'two') GIT.push() # Unresolvable conflict # TODO: this didn't work GIT.new('three') repo.make_one_commit('file.txt', DELTA2, 'three') GIT.push() # Local differs from origin GIT.new('four') repo.make_one_commit('file.txt', 'four', 'four') GIT.checkout('master') GIT.update('-v') lines = [first + ' original', 'c0d1dbb 0'] def test(branch, *items): actual = GIT.log('--oneline', branch) expected = list(items) + lines self.assertEqual(expected, actual) test('master') test('origin/master') lines.insert(0, second + ' master!') test('upstream/master') test('one', '2b7979a one') test('origin/one', '2b7979a one') test('two', '5478a38 two') test('origin/two', '5478a38 two') test('three', '6158500 three') test('origin/three', '6158500 three') test('four', '62584d2 four') test('origin/four', '62584d2 four')
def _get_files(self, *args): GIT.checkout('-b', 'A') repo.make_commit('1') repo.make_commit('2') three = repo.make_commit('3') repo.make_commit('4') five = repo.make_commit('5') repo.make_commit('6') GIT.checkout('master') GIT.multi_pick('-v', three, five, *args) files = sorted(i for i in os.listdir() if not i.startswith('.')) self.assertEqual(files, ['0', '3', '5'])
def test_change(self): GIT.checkout('-b', 'A') repo.make_commit('1') GIT.checkout('-b', 'B') repo.make_commit('2') GIT.checkout('-b', 'C') repo.make_commit('3') self.assertEqual(functions.branch_name(), 'C') GIT.rot('0', '-v') self.assertEqual(functions.branch_name(), 'C') GIT.rot('-v') self.assertEqual(functions.branch_name(), 'master') GIT.rot('-v') self.assertEqual(functions.branch_name(), 'A') GIT.rot('2', '-v') self.assertEqual(functions.branch_name(), 'C') GIT.rot('-1', '-v') self.assertEqual(functions.branch_name(), 'B') GIT.rot('-', '-v') self.assertEqual(functions.branch_name(), 'A') GIT.rot('-2', '-v') self.assertEqual(functions.branch_name(), 'C')
def test_clone(self): self.assertEqual('44dac6b', repo.make_commit('one.txt')) self.assertEqual('393ad1c', repo.make_commit('two.txt')) GIT.checkout('-b', 'working') repo.add_remotes(['foo', 'bar']) expected = ['bar', 'foo', 'origin', 'upstream'] self.assertEqual(sorted(GIT.remote()), expected) functions.fetch('foo') functions.fetch('bar') actual = functions.branches('-r') expected = [ 'bar/working', 'foo/working', 'origin/master', 'upstream/master', ] self.assertEqual(actual, expected) self.assertEqual('efc4ce6', repo.make_commit('three.txt')) GIT.push('foo', 'HEAD:working') self.assertEqual(functions.commit_id('bar/working'), '393ad1c') self.assertEqual(functions.commit_id('foo/working'), 'efc4ce6')
def test_branches(self): self.assertEqual('44dac6b', repo.make_commit('one.txt')) current = functions.branch_name() GIT.checkout('-b', 'foo') self.assertEqual(repo.make_commit('two.txt'), '393ad1c') GIT.checkout(current) GIT.checkout('-b', 'bar') self.assertEqual(repo.make_commit('three.txt'), 'b6aee43') actual = GIT.for_each('-', 'git', 'log', '--oneline') self.assertEqual(actual, _BRANCHES.split('\n'))