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_diverged_remote(self):
self._deploy()
stage_dir('alias_clone')
check_call_silent(['git', 'clone', self.stage, '.'])
check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
git_config()
with pushd(self.stage):
self._deploy(versions=['2.0'])
origin_rev = git_utils.get_latest_commit('gh-pages')
self._deploy(versions=['2.1'])
clone_rev = git_utils.get_latest_commit('gh-pages')
check_call_silent(['git', 'fetch', 'origin'])
assertOutput(self, ['mike', 'alias', '1.0', 'latest'], output=(
'mike: gh-pages has diverged from origin/gh-pages\n' +
' Pass --ignore to ignore this or --rebase to rebase onto ' +
'remote\n'
), returncode=1)
self.assertEqual(git_utils.get_latest_commit('gh-pages'), clone_rev)
assertPopen(['mike', 'alias', '--ignore', '1.0', 'latest'])
self.assertEqual(git_utils.get_latest_commit('gh-pages^'), clone_rev)
assertPopen(['mike', 'alias', '--rebase', '1.0', 'latest'])
self.assertEqual(git_utils.get_latest_commit('gh-pages^'), origin_rev)
def test_behind(self):
rev = git_utils.get_latest_commit('master')
check_call_silent(['git', 'checkout', 'master'])
commit_file('file2.txt', 'second commit')
self.assertEqual(git_utils.get_merge_base('branch', 'master'), rev)
self.assertEqual(git_utils.compare_branches('branch', 'master'),
git_utils.BranchStatus.behind)
def test_abort(self):
self._add_file('file.txt')
commit = git_utils.Commit('master', 'add file')
commit.add_file(git_utils.FileInfo('file2.txt', 'this is some text'))
commit.abort()
self.assertRaises(git_utils.GitError, commit.finish)
self.assertRaises(git_utils.GitError, commit.abort)
check_call_silent(['git', 'checkout', 'master'])
assertDirectory('.', {'file.txt'})
))
clone_rev = git_utils.get_latest_commit('gh-pages')
check_call_silent(['git', 'fetch', 'origin'])
self._check_list(stderr=(
'warning: gh-pages has diverged from origin/gh-pages\n' +
' Pass --ignore to ignore this or --rebase to rebase onto ' +
'remote\n'
))
self.assertEqual(git_utils.get_latest_commit('gh-pages'), clone_rev)
self._check_list(['--ignore'])
self.assertEqual(git_utils.get_latest_commit('gh-pages'), clone_rev)
self._check_list(['--rebase'])
self.assertEqual(git_utils.get_latest_commit('gh-pages'), origin_rev)
def test_ahead_remote(self):
self._deploy(versions=['1.0'])
origin_rev = git_utils.get_latest_commit('gh-pages')
stage_dir('deploy_clone')
check_call_silent(['git', 'clone', self.stage, '.'])
check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
git_config()
self._deploy(versions=['2.0'])
old_rev = git_utils.get_latest_commit('gh-pages')
assertPopen(['mike', 'delete', '1.0'])
self.assertEqual(git_utils.get_latest_commit('gh-pages^'), old_rev)
self.assertEqual(git_utils.get_latest_commit('gh-pages^^'), origin_rev)
def test_get_username(self):
self.assertEqual(git_utils.get_config('user.name'), 'username')
def test_walk(self):
files = sorted(git_utils.walk_real_files(self.directory),
key=lambda x: x.path)
path = os.path.join(self.directory, 'file.txt')
with open(path, 'rb') as f:
data = f.read()
self.assertEqual(files, [git_utils.FileInfo(path, data, self.mode)])
def versions_to_file_info(versions):
return git_utils.FileInfo(versions_file, versions.dumps())