Skip to content

Commit

Permalink
Fix update --force against the same version
Browse files Browse the repository at this point in the history
  • Loading branch information
doshitan committed Jan 15, 2025
1 parent 3c696b9 commit 4df161f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
7 changes: 4 additions & 3 deletions nava/platform/templates/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ def update(

self._checkout_copier_ref(version)

# if we are not just updating answers or providing data and are already
# running the version that would be installed, then skip
if (not answers_only or not passed_data) and self._is_same_version(existing_version):
# if we are already running the version that would be installed, then
# skip, unless overridden
bypass_same_version_check = force or (answers_only and passed_data)
if not bypass_same_version_check and self._is_same_version(existing_version):
self.ctx.console.print(f"Already up to date ({existing_version.display_str})")
return

Expand Down
24 changes: 23 additions & 1 deletion tests/cli/commands/infra/test_update_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,41 @@
def test_update_no_change(cli, infra_template, new_project, clean_install):
content_before_update = DirectoryContent.from_fs(new_project.dir, ignore=[".git"])

cli(
result = cli(
[
"infra",
"update",
str(new_project.dir),
"--template-uri",
str(infra_template.template_dir),
]
)

content_after_update = DirectoryContent.from_fs(new_project.dir, ignore=[".git"])
assert content_before_update == content_after_update

assert "Already up to date" in result.output


def test_update_no_change_force(cli, infra_template, new_project, clean_install):
content_before_update = DirectoryContent.from_fs(new_project.dir, ignore=[".git"])

result = cli(
[
"infra",
"update",
str(new_project.dir),
"--template-uri",
str(infra_template.template_dir),
"--force",
]
)

content_after_update = DirectoryContent.from_fs(new_project.dir, ignore=[".git"])
assert content_before_update == content_after_update

assert "Already up to date" not in result.output


def test_update_with_template_change(cli, infra_template, new_project, clean_install):
ChangeSet(
Expand Down

0 comments on commit 4df161f

Please sign in to comment.