diff --git a/CHANGELOG.md b/CHANGELOG.md index 464b611f0..bf2e3b0d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where * Bugfix: GPKG spatial indexes are now created and deleted properly regardless of the case (upper-case or lower-case) of the table name and geometry column. * `diff` now accepts `--only-feature-count`, which produces a feature count for the diff. The feature count can be exact or a fast estimate. * `log` now accepts `--with-feature-count` which adds a feature count to each commit when used with `-o json`. The feature count can be exact or a fast estimate. +* Fix help text for discarding changes to refer to `kart restore` instead of `kart reset`, as `kart restore` is now the simplest way to discard changes. [#426](https://github.com/koordinates/kart/issues/426) ## 0.9.0 (First "Kart" release) diff --git a/kart/checkout.py b/kart/checkout.py index 4d42f0bd9..3b26fd252 100644 --- a/kart/checkout.py +++ b/kart/checkout.py @@ -292,7 +292,8 @@ def _find_remote_branch_by_name(repo, name): @click.argument("pathspec", nargs=-1) def restore(ctx, source, pathspec): """ - Restore specified paths in the working copy with some contents from a restore source. + Restore specified paths in the working copy with some contents from the given restore source. + By default, restores the entire working copy to the commit at HEAD (so, discards all uncommitted changes). """ repo = ctx.obj.repo @@ -323,13 +324,20 @@ def restore(ctx, source, pathspec): is_flag=True, help="Discard local changes in working copy if necessary", ) -@click.argument("refish") +@click.argument("refish", default="HEAD") def reset(ctx, discard_changes, refish): """ - Reset the branch head to point to a different commit. + Reset the branch head to point to a particular commit. + Defaults to HEAD, which has no effect unless --discard-changes is also specified. """ repo = ctx.obj.repo + if refish == "HEAD" and not discard_changes: + raise InvalidOperation( + "Resetting the current branch to HEAD has no effect, unless you also discard changes.\n" + "Do you mean `kart reset --discard-changes?`" + ) + try: commit_or_tree, ref = repo.resolve_refish(refish) commit = commit_or_tree.peel(pygit2.Commit) diff --git a/kart/status.py b/kart/status.py index c953b9800..465db5175 100644 --- a/kart/status.py +++ b/kart/status.py @@ -152,7 +152,7 @@ def working_copy_status_to_text(jdict): return ( "Changes in working copy:\n" ' (use "kart commit" to commit)\n' - ' (use "kart reset" to discard changes)\n\n' + ' (use "kart restore" to discard changes)\n\n' + diff_status_to_text(jdict["changes"]) ) diff --git a/kart/working_copy/base.py b/kart/working_copy/base.py index 4d2680d83..110798647 100644 --- a/kart/working_copy/base.py +++ b/kart/working_copy/base.py @@ -437,7 +437,7 @@ def tracking_changes_count(self, dataset=None): def check_not_dirty(self, help_message=None): """Checks the working copy has no changes in it. Otherwise, raises InvalidOperation""" if not help_message: - help_message = "Commit these changes (`kart commit`) or discard these changes (`kart reset`) first." + help_message = "Commit these changes (`kart commit`) or discard these changes (`kart restore`) first." if self.is_dirty(): raise InvalidOperation( f"You have uncommitted changes in your working copy.\n{help_message}" diff --git a/kart/working_copy/gpkg_adapter.py b/kart/working_copy/gpkg_adapter.py index 76f74d91f..3f76fbbe0 100644 --- a/kart/working_copy/gpkg_adapter.py +++ b/kart/working_copy/gpkg_adapter.py @@ -562,7 +562,7 @@ def gpkg_metadata_to_xml(gpkg_metadata, gpkg_metadata_reference): # We can't actually commit a whole list of XML, but we need to return something that makes sense. # Simply throwing an error here stops dirty-detection working, and stops commands that would fix the situation - # from working, like `kart reset HEAD --discard-changes` or `kart create-workingcopy --discard-changes`. + # from working, like `kart reset --discard-changes` or `kart create-workingcopy --discard-changes`. return xml_list diff --git a/tests/test_status.py b/tests/test_status.py index 0f1794bbd..67174a2a7 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -216,7 +216,7 @@ def test_status( "", "Changes in working copy:", ' (use "kart commit" to commit)', - ' (use "kart reset" to discard changes)', + ' (use "kart restore" to discard changes)', "", f" {H.POINTS.LAYER}:", " feature:", diff --git a/tests/test_working_copy_gpkg.py b/tests/test_working_copy_gpkg.py index 9935b74a8..a4cbc413d 100644 --- a/tests/test_working_copy_gpkg.py +++ b/tests/test_working_copy_gpkg.py @@ -375,8 +375,8 @@ def test_working_copy_discard_changes( assert r.exit_code == 0, r elif via == "reset": - # using `kart reset HEAD --discard-changes` - r = cli_runner.invoke(["reset", "HEAD", "--discard-changes"]) + # using `kart reset --discard-changes` + r = cli_runner.invoke(["reset", "--discard-changes"]) assert r.exit_code == 0, r elif via == "checkout": diff --git a/tests/test_working_copy_mysql.py b/tests/test_working_copy_mysql.py index b5a45d58f..403ff75f9 100644 --- a/tests/test_working_copy_mysql.py +++ b/tests/test_working_copy_mysql.py @@ -166,7 +166,7 @@ def test_commit_edits( "", "Changes in working copy:", ' (use "kart commit" to commit)', - ' (use "kart reset" to discard changes)', + ' (use "kart restore" to discard changes)', "", f" {table}:", " feature:", diff --git a/tests/test_working_copy_postgis.py b/tests/test_working_copy_postgis.py index 1b35e0ae9..7c8958bb7 100644 --- a/tests/test_working_copy_postgis.py +++ b/tests/test_working_copy_postgis.py @@ -168,7 +168,7 @@ def test_commit_edits( "", "Changes in working copy:", ' (use "kart commit" to commit)', - ' (use "kart reset" to discard changes)', + ' (use "kart restore" to discard changes)', "", f" {table}:", " feature:", diff --git a/tests/test_working_copy_sqlserver.py b/tests/test_working_copy_sqlserver.py index 96e34e017..071693a82 100644 --- a/tests/test_working_copy_sqlserver.py +++ b/tests/test_working_copy_sqlserver.py @@ -212,7 +212,7 @@ def test_commit_edits( "", "Changes in working copy:", ' (use "kart commit" to commit)', - ' (use "kart reset" to discard changes)', + ' (use "kart restore" to discard changes)', "", f" {table}:", " feature:",