Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions fs_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,16 +870,25 @@ def commit_pushed(
workspace: Workspace, pushed: list[Studio | Image], deleted: list[Studio | Image], updated: list[Studio]
) -> None:
"""Commits what `fs push` pushed and deleted, as it is in Onshape now (imports by path resolved to ids, and
import versions from Onshape), with fs-studios.json, so the repo matches Onshape. Nothing else is committed."""
if not pushed and not deleted:
import versions from Onshape), and the import versions it took from Onshape for files it didn't push, with
fs-studios.json, so the repo matches Onshape. Nothing else is committed."""
if not pushed and not deleted and not updated:
return
names = [pathlib.PurePosixPath(item.path).name for item in pushed]
subject = (
f"Push {', '.join(names)} to Onshape"
if 0 < len(names) <= 3
else f"Push {_plural(len(names), 'file')} to Onshape" if names else "Delete tabs in Onshape"
else f"Push {_plural(len(names), 'file')} to Onshape"
if names
else "Delete tabs in Onshape"
if deleted
else "Take import versions from Onshape"
)
lines = (
[f"Pushed {item.path}" for item in pushed]
+ [f"Deleted the tab of {item.path}" for item in deleted]
+ [f"Took import versions in {item.path}" for item in updated if item not in pushed]
)
lines = [f"Pushed {item.path}" for item in pushed] + [f"Deleted the tab of {item.path}" for item in deleted]
paths = [item.file for item in [*pushed, *deleted, *updated]] + [workspace.config.studios_path]
# fs-studios.json as the push left it (`main` saves it again after)
workspace.state.save()
Expand Down
14 changes: 14 additions & 0 deletions tests/fs_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,20 @@ def test_pushing_a_tab_with_its_importer_keeps_the_version_onshape_gives_the_imp
assert "import versions updated in Onshape" not in capsys.readouterr().out


def test_a_push_with_nothing_to_push_commits_the_import_versions_it_took(repo, onshape, capsys):
"""So the tree is clean after it, as `fs run-releases` needs after `fs sync-main`."""
git_repo(repo)
element_id = onshape.add("b.fs", importing(OLD))
run(onshape, "pull")
commit_all(repo, "Pull")
onshape.edit(element_id, importing(NEW))

assert run(onshape, "push", "--force") == 0
assert local(repo, "b.fs").read_text() == importing(NEW)
assert git_output(repo, "status", "--porcelain") == ""
assert git_output(repo, "log", "-1", "--format=%s") == "Take import versions from Onshape\n"


def test_pushing_keeps_onshapes_import_versions(repo, onshape):
element_id = onshape.add("b.fs", importing(OLD))
run(onshape, "pull")
Expand Down
Loading