Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_even(self):
old_rev = git_utils.get_latest_commit('master')
git_utils.try_rebase_branch('origin', 'master')
new_rev = git_utils.get_latest_commit('master')
self.assertEqual(old_rev, new_rev)
def test_diverged(self):
commit_file('file2.txt', 'add file2')
old_rev = git_utils.get_latest_commit('master')
with pushd(self.origin):
commit_file('file2-origin.txt', 'add file2')
check_call_silent(['git', 'fetch', 'origin'])
self.assertRaises(git_utils.GitBranchDiverged,
git_utils.try_rebase_branch, 'origin', 'master')
new_rev = git_utils.get_latest_commit('master')
self.assertEqual(old_rev, new_rev)
def test_nonexistent_remote(self):
old_rev = git_utils.get_latest_commit('master')
check_call_silent(['git', 'fetch', 'origin'])
git_utils.try_rebase_branch('upstream', 'master')
new_rev = git_utils.get_latest_commit('master')
self.assertEqual(old_rev, new_rev)
def test_ahead(self):
commit_file('file2.txt', 'add file2')
old_rev = git_utils.get_latest_commit('master')
git_utils.try_rebase_branch('origin', 'master')
new_rev = git_utils.get_latest_commit('master')
self.assertEqual(old_rev, new_rev)
def check_remote_status(args, strict=False):
if args.ignore:
return
try:
git_utils.try_rebase_branch(args.remote, args.branch,
force=args.rebase)
except (git_utils.GitBranchDiverged, git_utils.GitRevUnrelated) as e:
msg = (str(e) + '\n Pass --ignore to ignore this or --rebase to ' +
'rebase onto remote')
if strict:
raise ValueError(msg)
else:
sys.stderr.write('warning: {}\n'.format(msg))