ff
This commit is contained in:
@@ -436,10 +436,14 @@ def upgrade(ctx, branch):
|
|||||||
commandSequences.append(['git', 'reset', '--hard', 'HEAD'])
|
commandSequences.append(['git', 'reset', '--hard', 'HEAD'])
|
||||||
|
|
||||||
if branch:
|
if branch:
|
||||||
commandSequences.append(['git', 'checkout', branch])
|
commandSequences += [
|
||||||
|
['git', 'fetch', 'origin', branch],
|
||||||
|
['git', 'checkout', '-B', branch, 'FETCH_HEAD'],
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
commandSequences.append(['git', 'pull'])
|
||||||
|
|
||||||
commandSequences += [
|
commandSequences += [
|
||||||
['git', 'pull'],
|
|
||||||
[bundlePipPath, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'],
|
[bundlePipPath, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'],
|
||||||
[bundlePipPath, 'install', '--editable', '.'],
|
[bundlePipPath, 'install', '--editable', '.'],
|
||||||
]
|
]
|
||||||
|
|||||||
BIN
tests/assets/dball_S01E89_3_und.sup
Normal file
BIN
tests/assets/dball_S01E89_3_und.sup
Normal file
Binary file not shown.
BIN
tests/assets/dball_S01E89_4_und.sup
Normal file
BIN
tests/assets/dball_S01E89_4_und.sup
Normal file
Binary file not shown.
@@ -57,7 +57,7 @@ class UpgradeCommandTests(unittest.TestCase):
|
|||||||
self.assertTrue(subprocess_calls[0][1]["capture_output"])
|
self.assertTrue(subprocess_calls[0][1]["capture_output"])
|
||||||
self.assertTrue(subprocess_calls[0][1]["text"])
|
self.assertTrue(subprocess_calls[0][1]["text"])
|
||||||
|
|
||||||
def test_upgrade_resets_before_checkout_and_pull_when_user_confirms(self):
|
def test_upgrade_resets_then_fetches_and_checks_out_requested_branch_when_user_confirms(self):
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
repo_path = "/tmp/ffx-repo"
|
repo_path = "/tmp/ffx-repo"
|
||||||
pip_path = "/tmp/ffx-venv/bin/pip"
|
pip_path = "/tmp/ffx-venv/bin/pip"
|
||||||
@@ -85,8 +85,8 @@ class UpgradeCommandTests(unittest.TestCase):
|
|||||||
[
|
[
|
||||||
['git', 'status', '--porcelain', '--untracked-files=no'],
|
['git', 'status', '--porcelain', '--untracked-files=no'],
|
||||||
['git', 'reset', '--hard', 'HEAD'],
|
['git', 'reset', '--hard', 'HEAD'],
|
||||||
['git', 'checkout', 'main'],
|
['git', 'fetch', 'origin', 'main'],
|
||||||
['git', 'pull'],
|
['git', 'checkout', '-B', 'main', 'FETCH_HEAD'],
|
||||||
[pip_path, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'],
|
[pip_path, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'],
|
||||||
[pip_path, 'install', '--editable', '.'],
|
[pip_path, 'install', '--editable', '.'],
|
||||||
],
|
],
|
||||||
@@ -95,6 +95,39 @@ class UpgradeCommandTests(unittest.TestCase):
|
|||||||
for args, kwargs in subprocess_calls[1:]:
|
for args, kwargs in subprocess_calls[1:]:
|
||||||
self.assertEqual(repo_path, kwargs["cwd"], args)
|
self.assertEqual(repo_path, kwargs["cwd"], args)
|
||||||
|
|
||||||
|
def test_upgrade_pulls_current_branch_when_no_branch_is_requested(self):
|
||||||
|
runner = CliRunner()
|
||||||
|
repo_path = "/tmp/ffx-repo"
|
||||||
|
pip_path = "/tmp/ffx-venv/bin/pip"
|
||||||
|
|
||||||
|
subprocess_calls = []
|
||||||
|
|
||||||
|
def fake_run(args, **kwargs):
|
||||||
|
subprocess_calls.append((args, kwargs))
|
||||||
|
if args == ['git', 'status', '--porcelain', '--untracked-files=no']:
|
||||||
|
return self.make_completed(args, stdout="")
|
||||||
|
return self.make_completed(args)
|
||||||
|
|
||||||
|
with (
|
||||||
|
patch.object(cli, "getBundleRepoPath", return_value=repo_path),
|
||||||
|
patch.object(cli, "getBundlePipPath", return_value=pip_path),
|
||||||
|
patch.object(cli.os.path, "isdir", return_value=True),
|
||||||
|
patch.object(cli.os.path, "isfile", return_value=True),
|
||||||
|
patch.object(cli.subprocess, "run", side_effect=fake_run),
|
||||||
|
):
|
||||||
|
result = runner.invoke(cli.ffx, ["upgrade"])
|
||||||
|
|
||||||
|
self.assertEqual(0, result.exit_code, result.output)
|
||||||
|
self.assertEqual(
|
||||||
|
[
|
||||||
|
['git', 'status', '--porcelain', '--untracked-files=no'],
|
||||||
|
['git', 'pull'],
|
||||||
|
[pip_path, 'install', '--upgrade', 'pip', 'setuptools', 'wheel'],
|
||||||
|
[pip_path, 'install', '--editable', '.'],
|
||||||
|
],
|
||||||
|
[call[0] for call in subprocess_calls],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user