git-project-core-plugins 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/PKG-INFO +9 -9
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/_version.py +2 -2
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/changelog.rst +20 -1
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/requirements.txt +1 -2
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/branch.py +6 -1
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/clone.py +6 -3
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/multirepo.py +2 -3
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/worktree.py +70 -6
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_branch.py +17 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_clone.py +10 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_worktree.py +218 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/.gitignore +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/COPYING +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/MANIFEST.in +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/changelog.d/README.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/changelog.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/Makefile +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/authors.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/commands.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/conf.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/contributing.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/index.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/intro.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/license.rst +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/docs/make.bat +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/hatch_build.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/pyproject.toml +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/__init__.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/_commanddocs.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/artifact.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/common.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/config.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/help.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/init.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/src/git_project_core_plugins/run.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/common.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/conftest.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_artifact.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_changelog.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_config.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_help.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_init.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_multirepo.py +0 -0
- {git_project_core_plugins-0.1.0 → git_project_core_plugins-0.1.2}/tests/test_run.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: git-project-core-plugins
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: The extensible stupid project manager - core functionality
|
|
5
5
|
Author-email: "David A. Greene" <dag@obbligato.org>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -14,9 +14,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
16
16
|
Requires-Python: >=3.10
|
|
17
|
-
Requires-Dist: git-project>=0.1.
|
|
17
|
+
Requires-Dist: git-project>=0.1.2
|
|
18
18
|
Requires-Dist: pygit2>=1.18.2
|
|
19
|
-
Requires-Dist: pytest-console-scripts
|
|
20
19
|
Provides-Extra: test
|
|
21
20
|
Requires-Dist: git-project; extra == 'test'
|
|
22
21
|
Requires-Dist: pytest; extra == 'test'
|
|
@@ -258,8 +257,8 @@ Summary::
|
|
|
258
257
|
By itself clone does a basic clone, then sets the project's defaults in
|
|
259
258
|
the new repository. With no <path> it clones into the last component of
|
|
260
259
|
<url> under the current directory, keeping any ``.git`` suffix, where
|
|
261
|
-
``git clone`` drops it.
|
|
262
|
-
|
|
260
|
+
``git clone`` drops it. An ssh url clones through git, so it uses your
|
|
261
|
+
ssh agent and ``~/.ssh/config`` as ``git clone`` does.
|
|
263
262
|
|
|
264
263
|
Plugins add options to clone. For example, the worktree command adds a
|
|
265
264
|
--worktree option to have clone create an ``umbrella layout``.
|
|
@@ -621,9 +620,8 @@ it over the file, so a failure leaves the file as it was. A symlink to
|
|
|
621
620
|
the set file stays a symlink.
|
|
622
621
|
|
|
623
622
|
``set clone`` clones each member whose root does not exist, as ``clone
|
|
624
|
-
--worktree <url> <root>`` does, one at a time.
|
|
625
|
-
|
|
626
|
-
root is already an umbrella cloned from its url is left alone. A root
|
|
623
|
+
--worktree <url> <root>`` does, one at a time. A member whose root is
|
|
624
|
+
already an umbrella cloned from its url is left alone. A root
|
|
627
625
|
that exists and is anything else stops the command before anything is
|
|
628
626
|
cloned, so a clone that failed partway is never taken for a finished
|
|
629
627
|
one. A failed clone does not stop the rest. Ctrl-C, SIGTERM and SIGHUP
|
|
@@ -688,7 +686,9 @@ project remote, unless a flag says otherwise: ``--keep-branch`` leaves the
|
|
|
688
686
|
branch alone everywhere, and ``--keep-remote-branch`` deletes only the
|
|
689
687
|
local copy. A branch the project configures is never deleted, whatever the
|
|
690
688
|
flags say. Removing a worktree whose branch is unmerged requires ``-f``,
|
|
691
|
-
unless ``--keep-branch`` means the branch survives anyway.
|
|
689
|
+
unless ``--keep-branch`` means the branch survives anyway. When <name> has
|
|
690
|
+
no worktree record, as after an ``rm`` that stopped part way, ``worktree
|
|
691
|
+
rm`` removes each path record that names <name> and changes nothing else.
|
|
692
692
|
|
|
693
693
|
With ``--check``, ``worktree add`` and ``worktree rm`` make the checks
|
|
694
694
|
they would make before changing anything, report the result and change
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1,
|
|
21
|
+
__version__ = version = '0.1.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 2)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -31,6 +31,23 @@ ChangeLog
|
|
|
31
31
|
`Unreleased`_
|
|
32
32
|
-------------
|
|
33
33
|
|
|
34
|
+
`0.1.2`_ - 2026-10-22
|
|
35
|
+
---------------------
|
|
36
|
+
Changed
|
|
37
|
+
.......
|
|
38
|
+
- The help for ``clone`` and ``set clone`` no longer says an ssh url fails to authenticate. Both now need git-project 0.1.2, which clones an ssh url through git, with your ssh agent and ``~/.ssh/config``.
|
|
39
|
+
|
|
40
|
+
Fixed
|
|
41
|
+
.....
|
|
42
|
+
- Installing git-project-core-plugins no longer installs ``pytest-console-scripts``. Only the tests use it, and the ``test`` extra already lists it.
|
|
43
|
+
- ``worktree rm <name>`` now removes each path record that names ``<name>`` when the worktree record of ``<name>`` is gone, as after an ``rm`` that stopped part way. It changes no other config and removes no files. Before, it said git-project had no record of the worktree and left the path record in place.
|
|
44
|
+
|
|
45
|
+
`0.1.1`_ - 2026-10-19
|
|
46
|
+
---------------------
|
|
47
|
+
Added
|
|
48
|
+
.....
|
|
49
|
+
- ``--menu=json`` hints worktree, branch and clone arguments with ``complete``, and offers the recorded worktree names as ``candidates`` for ``worktree rm``. Needs git-project 0.1.1.
|
|
50
|
+
|
|
34
51
|
`0.1.0`_ - 2026-10-15
|
|
35
52
|
---------------------
|
|
36
53
|
Changed
|
|
@@ -281,7 +298,9 @@ Fixed
|
|
|
281
298
|
404. Issues named ``unknown/greened``, a leftover from hatch's project
|
|
282
299
|
template, and Documentation misspelled the package name.
|
|
283
300
|
|
|
284
|
-
.. _Unreleased: https://github.com/greened/git-project-core-plugins/compare/v0.1.
|
|
301
|
+
.. _Unreleased: https://github.com/greened/git-project-core-plugins/compare/v0.1.2...HEAD
|
|
302
|
+
.. _0.1.2: https://github.com/greened/git-project-core-plugins/compare/v0.1.1...v0.1.2
|
|
303
|
+
.. _0.1.1: https://github.com/greened/git-project-core-plugins/compare/v0.1.0...v0.1.1
|
|
285
304
|
.. _0.1.0: https://github.com/greened/git-project-core-plugins/compare/v0.0.33...v0.1.0
|
|
286
305
|
.. _0.0.33: https://github.com/greened/git-project-core-plugins/compare/v0.0.32...v0.0.33
|
|
287
306
|
.. _0.0.32: https://github.com/greened/git-project-core-plugins/compare/v0.0.31...v0.0.32
|
|
@@ -263,10 +263,14 @@ class BranchPlugin(Plugin):
|
|
|
263
263
|
branch_status_parser.add_argument(
|
|
264
264
|
"name_or_ref",
|
|
265
265
|
nargs="?",
|
|
266
|
+
complete="branch",
|
|
266
267
|
help="Branch or pattern to filter branches",
|
|
267
268
|
)
|
|
268
269
|
branch_status_parser.add_argument(
|
|
269
|
-
"target",
|
|
270
|
+
"target",
|
|
271
|
+
nargs="?",
|
|
272
|
+
complete="branch",
|
|
273
|
+
help="Target branch to check against",
|
|
270
274
|
)
|
|
271
275
|
branch_status_parser.add_argument(
|
|
272
276
|
"--all", action="store_true", help="Show all branches"
|
|
@@ -288,6 +292,7 @@ class BranchPlugin(Plugin):
|
|
|
288
292
|
branch_prune_parser.add_argument(
|
|
289
293
|
"name_or_ref",
|
|
290
294
|
nargs="?",
|
|
295
|
+
complete="branch",
|
|
291
296
|
help="Branch name or pattern to filter branches",
|
|
292
297
|
)
|
|
293
298
|
branch_prune_parser.add_argument(
|
|
@@ -62,8 +62,8 @@ class ClonePlugin(Plugin):
|
|
|
62
62
|
By itself clone does a basic clone, then sets the project's defaults in
|
|
63
63
|
the new repository. With no <path> it clones into the last component of
|
|
64
64
|
<url> under the current directory, keeping any ``.git`` suffix, where
|
|
65
|
-
``git clone`` drops it.
|
|
66
|
-
|
|
65
|
+
``git clone`` drops it. An ssh url clones through git, so it uses your
|
|
66
|
+
ssh agent and ``~/.ssh/config`` as ``git clone`` does.
|
|
67
67
|
|
|
68
68
|
Plugins add options to clone. For example, the worktree command adds a
|
|
69
69
|
--worktree option to have clone create an ``umbrella layout``.
|
|
@@ -93,7 +93,10 @@ class ClonePlugin(Plugin):
|
|
|
93
93
|
clone_parser.add_argument("url", help="URL to clone")
|
|
94
94
|
|
|
95
95
|
clone_parser.add_argument(
|
|
96
|
-
"path",
|
|
96
|
+
"path",
|
|
97
|
+
nargs="?",
|
|
98
|
+
complete="directory",
|
|
99
|
+
help="Local repository location",
|
|
97
100
|
)
|
|
98
101
|
|
|
99
102
|
clone_parser.add_argument(
|
|
@@ -1331,9 +1331,8 @@ class SetPlugin(Plugin):
|
|
|
1331
1331
|
the set file stays a symlink.
|
|
1332
1332
|
|
|
1333
1333
|
``set clone`` clones each member whose root does not exist, as ``clone
|
|
1334
|
-
--worktree <url> <root>`` does, one at a time.
|
|
1335
|
-
|
|
1336
|
-
root is already an umbrella cloned from its url is left alone. A root
|
|
1334
|
+
--worktree <url> <root>`` does, one at a time. A member whose root is
|
|
1335
|
+
already an umbrella cloned from its url is left alone. A root
|
|
1337
1336
|
that exists and is anything else stops the command before anything is
|
|
1338
1337
|
cloned, so a clone that failed partway is never taken for a finished
|
|
1339
1338
|
one. A failed clone does not stop the rest. Ctrl-C, SIGTERM and SIGHUP
|
|
@@ -418,6 +418,32 @@ def _record_values(git, worktree, key):
|
|
|
418
418
|
)
|
|
419
419
|
|
|
420
420
|
|
|
421
|
+
def _path_sections_naming(git, project, name):
|
|
422
|
+
"""Return the section and path of each path record that names worktree
|
|
423
|
+
name.
|
|
424
|
+
|
|
425
|
+
"""
|
|
426
|
+
section = project.get_section()
|
|
427
|
+
# A live worktree's own path record is never an orphan, even if its
|
|
428
|
+
# worktree key was edited to name this one.
|
|
429
|
+
live = set()
|
|
430
|
+
for ident in ConfigObject.iter_idents(git, section, Worktree.subsection()):
|
|
431
|
+
worktree = Worktree.get(git, project, ident)
|
|
432
|
+
project.pop_scope()
|
|
433
|
+
live.update(_record_values(git, worktree, "path"))
|
|
434
|
+
sections = []
|
|
435
|
+
for path in ConfigObject.iter_idents(
|
|
436
|
+
git, section, Worktree.Path.subsection()
|
|
437
|
+
):
|
|
438
|
+
if path in live:
|
|
439
|
+
continue
|
|
440
|
+
record = Worktree.Path.get(git, section, path)
|
|
441
|
+
# Skip a record with several worktree values rather than guess.
|
|
442
|
+
if _record_values(git, record, "worktree") == [name]:
|
|
443
|
+
sections.append((record.get_section(), path))
|
|
444
|
+
return sections
|
|
445
|
+
|
|
446
|
+
|
|
421
447
|
def _plan_worktree_rm(git, project, clargs):
|
|
422
448
|
"""Check that worktree rm can go ahead, changing nothing. Return whether
|
|
423
449
|
the worktree's branch stays.
|
|
@@ -478,13 +504,37 @@ def _plan_worktree_rm(git, project, clargs):
|
|
|
478
504
|
|
|
479
505
|
def command_worktree_rm(git, gitproject, project, clargs):
|
|
480
506
|
"""Implement git-project worktree rm."""
|
|
507
|
+
name = clargs.name
|
|
508
|
+
# A path record can outlive its worktree record, as when an rm stops
|
|
509
|
+
# between its two section removals. Remove such a record, config only.
|
|
510
|
+
# With --multirepo, refuse, since the record that names the set is gone.
|
|
511
|
+
if getattr(clargs, "multirepo", None) is None and not Worktree.exists(
|
|
512
|
+
git, project.get_section(), Worktree.subsection(), name
|
|
513
|
+
):
|
|
514
|
+
orphans = _path_sections_naming(git, project, name)
|
|
515
|
+
if orphans:
|
|
516
|
+
check = getattr(clargs, "check", False)
|
|
517
|
+
for section, path in orphans:
|
|
518
|
+
if check:
|
|
519
|
+
print(
|
|
520
|
+
f"Would remove the orphan path record {section}, "
|
|
521
|
+
f"and keep the worktree directory {path}"
|
|
522
|
+
)
|
|
523
|
+
else:
|
|
524
|
+
_rm_config_section(git, section)
|
|
525
|
+
print(
|
|
526
|
+
f"Removed the orphan path record {section}, and "
|
|
527
|
+
f"kept the worktree directory {path}"
|
|
528
|
+
)
|
|
529
|
+
return
|
|
530
|
+
|
|
481
531
|
keep_branch = _plan_worktree_rm(git, project, clargs)
|
|
482
532
|
|
|
483
533
|
if getattr(clargs, "check", False):
|
|
484
|
-
print(f"Would remove worktree {
|
|
534
|
+
print(f"Would remove worktree {name}")
|
|
485
535
|
return
|
|
486
536
|
|
|
487
|
-
Worktree.get(git, project,
|
|
537
|
+
Worktree.get(git, project, name).rm(
|
|
488
538
|
keep_branch=keep_branch,
|
|
489
539
|
keep_remote_branch=clargs.keep_remote_branch,
|
|
490
540
|
)
|
|
@@ -1975,7 +2025,9 @@ class WorktreePlugin(Plugin):
|
|
|
1975
2025
|
branch alone everywhere, and ``--keep-remote-branch`` deletes only the
|
|
1976
2026
|
local copy. A branch the project configures is never deleted, whatever the
|
|
1977
2027
|
flags say. Removing a worktree whose branch is unmerged requires ``-f``,
|
|
1978
|
-
unless ``--keep-branch`` means the branch survives anyway.
|
|
2028
|
+
unless ``--keep-branch`` means the branch survives anyway. When <name> has
|
|
2029
|
+
no worktree record, as after an ``rm`` that stopped part way, ``worktree
|
|
2030
|
+
rm`` removes each path record that names <name> and changes nothing else.
|
|
1979
2031
|
|
|
1980
2032
|
With ``--check``, ``worktree add`` and ``worktree rm`` make the checks
|
|
1981
2033
|
they would make before changing anything, report the result and change
|
|
@@ -2284,10 +2336,13 @@ class WorktreePlugin(Plugin):
|
|
|
2284
2336
|
worktree_add_parser.set_defaults(func=command_worktree_add)
|
|
2285
2337
|
|
|
2286
2338
|
worktree_add_parser.add_argument(
|
|
2287
|
-
"path", help="Path for worktree checkout"
|
|
2339
|
+
"path", complete="directory", help="Path for worktree checkout"
|
|
2288
2340
|
)
|
|
2289
2341
|
worktree_add_parser.add_argument(
|
|
2290
|
-
"committish",
|
|
2342
|
+
"committish",
|
|
2343
|
+
nargs="?",
|
|
2344
|
+
complete="committish",
|
|
2345
|
+
help="Branch point for worktree",
|
|
2291
2346
|
)
|
|
2292
2347
|
worktree_add_parser.add_argument(
|
|
2293
2348
|
"-b",
|
|
@@ -2313,7 +2368,16 @@ class WorktreePlugin(Plugin):
|
|
|
2313
2368
|
|
|
2314
2369
|
worktree_rm_parser.set_defaults(func=command_worktree_rm)
|
|
2315
2370
|
|
|
2316
|
-
worktree_rm_parser.add_argument(
|
|
2371
|
+
worktree_rm_parser.add_argument(
|
|
2372
|
+
"name",
|
|
2373
|
+
complete="worktree",
|
|
2374
|
+
candidates=sorted(
|
|
2375
|
+
ConfigObject.iter_idents(
|
|
2376
|
+
git, project.get_section(), Worktree.subsection()
|
|
2377
|
+
)
|
|
2378
|
+
),
|
|
2379
|
+
help="Worktree to remove",
|
|
2380
|
+
)
|
|
2317
2381
|
worktree_rm_parser.add_argument(
|
|
2318
2382
|
"-f",
|
|
2319
2383
|
"--force",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
# with git-project. If not, see <https://www.gnu.org/licenses/>.
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
import json
|
|
26
|
+
|
|
25
27
|
import common
|
|
26
28
|
|
|
27
29
|
from git_project_core_plugins import BranchPlugin
|
|
@@ -279,3 +281,18 @@ def test_branch_status_target(
|
|
|
279
281
|
assert lines["refs/heads/master"] == "yes"
|
|
280
282
|
assert lines["refs/heads/unmerged"] == "no"
|
|
281
283
|
assert lines["refs/heads/notpushed"] == "no"
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def test_branch_menu_hints(reset_directory, git, script_runner):
|
|
287
|
+
def positionals(command):
|
|
288
|
+
ret = script_runner.run(
|
|
289
|
+
"git-project", "branch", command, "--menu=json"
|
|
290
|
+
)
|
|
291
|
+
assert ret.success
|
|
292
|
+
return json.loads(ret.stdout)["positionals"]
|
|
293
|
+
|
|
294
|
+
assert [pos["complete"] for pos in positionals("status")] == [
|
|
295
|
+
"branch",
|
|
296
|
+
"branch",
|
|
297
|
+
]
|
|
298
|
+
assert [pos["complete"] for pos in positionals("prune")] == ["branch"]
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
# You should have received a copy of the GNU Affero General Public License along
|
|
22
22
|
# with git-project. If not, see <https://www.gnu.org/licenses/>.
|
|
23
23
|
|
|
24
|
+
import json
|
|
24
25
|
import os
|
|
25
26
|
from pathlib import Path
|
|
26
27
|
|
|
@@ -137,3 +138,12 @@ def test_clone_path(
|
|
|
137
138
|
assert os.path.exists(gitdir)
|
|
138
139
|
assert os.path.exists(Path(gitdir) / ".git")
|
|
139
140
|
assert gitdir == str(clone_path)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_clone_menu_hints(reset_directory, script_runner):
|
|
144
|
+
ret = script_runner.run("git-project", "clone", "--menu=json")
|
|
145
|
+
assert ret.success
|
|
146
|
+
|
|
147
|
+
url, path = json.loads(ret.stdout)["positionals"]
|
|
148
|
+
assert url["complete"] is None
|
|
149
|
+
assert path["complete"] == "directory"
|
|
@@ -1718,6 +1718,41 @@ def test_worktree_migrate_existing_worktree_config(flat_clone, script_runner):
|
|
|
1718
1718
|
)
|
|
1719
1719
|
|
|
1720
1720
|
|
|
1721
|
+
def test_worktree_rm_after_migrate_removes_the_stale_path_record(
|
|
1722
|
+
flat_clone, script_runner
|
|
1723
|
+
):
|
|
1724
|
+
fc = flat_clone
|
|
1725
|
+
top = str(fc.top)
|
|
1726
|
+
old = f"project.worktreepath.{fc.feature}.worktree"
|
|
1727
|
+
_out("-C", top, "config", "project.worktree.feat.path", str(fc.feature))
|
|
1728
|
+
_out(
|
|
1729
|
+
"-C", top, "config", "project.worktree.feat.committish", "user/feature"
|
|
1730
|
+
)
|
|
1731
|
+
_out("-C", top, "config", old, "feat")
|
|
1732
|
+
assert _migrate(script_runner, fc.top, "--apply").success
|
|
1733
|
+
new = fc.top / "user-feature"
|
|
1734
|
+
|
|
1735
|
+
def rm():
|
|
1736
|
+
return script_runner.run(
|
|
1737
|
+
["git-project", "worktree", "rm", "-f", "feat"],
|
|
1738
|
+
cwd=str(fc.top / "master"),
|
|
1739
|
+
)
|
|
1740
|
+
|
|
1741
|
+
result = rm()
|
|
1742
|
+
assert result.success, result.stdout + result.stderr
|
|
1743
|
+
# A stale record names a path that no worktree owns, so it survives
|
|
1744
|
+
# the rm of the live worktree.
|
|
1745
|
+
assert not new.exists()
|
|
1746
|
+
assert _out("-C", top, "config", old) == "feat\n"
|
|
1747
|
+
|
|
1748
|
+
result = rm()
|
|
1749
|
+
assert result.success, result.stdout + result.stderr
|
|
1750
|
+
assert f"Removed the orphan path record {old[: -len('.worktree')]}" in (
|
|
1751
|
+
result.stdout
|
|
1752
|
+
)
|
|
1753
|
+
assert "=feat\n" not in _out("-C", top, "config", "--list", "--local")
|
|
1754
|
+
|
|
1755
|
+
|
|
1721
1756
|
def _unpushed(result):
|
|
1722
1757
|
return [
|
|
1723
1758
|
line
|
|
@@ -3295,6 +3330,164 @@ def test_worktree_rm_multirepo_deletes_a_branch_it_created(
|
|
|
3295
3330
|
assert not (workarea / "wt-d").exists()
|
|
3296
3331
|
|
|
3297
3332
|
|
|
3333
|
+
def _path_records(git):
|
|
3334
|
+
"""Return each path record on disk, as path -> worktree name."""
|
|
3335
|
+
config = pygit2.Config(str(Path(git.get_git_common_dir()) / "config"))
|
|
3336
|
+
prefix = "project.worktreepath."
|
|
3337
|
+
return {
|
|
3338
|
+
entry.name[len(prefix) : -len(".worktree")]: entry.value
|
|
3339
|
+
for entry in config
|
|
3340
|
+
if entry.name.startswith(prefix) and entry.name.endswith(".worktree")
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
|
|
3344
|
+
def _orphan(git, gitproject, project, workarea, path):
|
|
3345
|
+
"""Add a worktree, then remove only its worktree record, as an rm that
|
|
3346
|
+
stopped between its two section removals would.
|
|
3347
|
+
|
|
3348
|
+
"""
|
|
3349
|
+
_add(git, gitproject, project, path)
|
|
3350
|
+
name = Path(path).name
|
|
3351
|
+
for key in list(_record(git, name)):
|
|
3352
|
+
git.config.rm_items(f"project.worktree.{name}", key)
|
|
3353
|
+
assert _record(git, name) == {}
|
|
3354
|
+
return str(workarea / name)
|
|
3355
|
+
|
|
3356
|
+
|
|
3357
|
+
def test_worktree_rm_removes_an_orphan_path_record(
|
|
3358
|
+
git, gitproject, project, capsys
|
|
3359
|
+
):
|
|
3360
|
+
workarea = _base()
|
|
3361
|
+
_add(git, gitproject, project, "../wt-keep")
|
|
3362
|
+
path = _orphan(git, gitproject, project, workarea, "../wt-o")
|
|
3363
|
+
assert _path_records(git)[path] == "wt-o"
|
|
3364
|
+
repo = pygit2.Repository(git.get_git_common_dir())
|
|
3365
|
+
refs = sorted(repo.references)
|
|
3366
|
+
worktrees = sorted(repo.list_worktrees())
|
|
3367
|
+
|
|
3368
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs("wt-o"))
|
|
3369
|
+
|
|
3370
|
+
assert (
|
|
3371
|
+
f"Removed the orphan path record project.worktreepath.{path}"
|
|
3372
|
+
in capsys.readouterr().out
|
|
3373
|
+
)
|
|
3374
|
+
# Config only, and another worktree's records stay.
|
|
3375
|
+
assert _path_records(git) == {str(workarea / "wt-keep"): "wt-keep"}
|
|
3376
|
+
assert _record(git, "wt-keep")["path"] == [str(workarea / "wt-keep")]
|
|
3377
|
+
assert (workarea / "wt-o").is_dir()
|
|
3378
|
+
repo = pygit2.Repository(git.get_git_common_dir())
|
|
3379
|
+
assert sorted(repo.references) == refs
|
|
3380
|
+
assert sorted(repo.list_worktrees()) == worktrees
|
|
3381
|
+
|
|
3382
|
+
|
|
3383
|
+
def test_worktree_rm_check_keeps_an_orphan_path_record(
|
|
3384
|
+
git, gitproject, project, capsys
|
|
3385
|
+
):
|
|
3386
|
+
workarea = _base()
|
|
3387
|
+
path = _orphan(git, gitproject, project, workarea, "../wt-o")
|
|
3388
|
+
before = _repo_state(git)
|
|
3389
|
+
|
|
3390
|
+
command_worktree_rm(
|
|
3391
|
+
git, gitproject, project, _rm_clargs("wt-o", check=True)
|
|
3392
|
+
)
|
|
3393
|
+
|
|
3394
|
+
assert (
|
|
3395
|
+
f"Would remove the orphan path record project.worktreepath.{path}"
|
|
3396
|
+
in capsys.readouterr().out
|
|
3397
|
+
)
|
|
3398
|
+
assert _repo_state(git) == before
|
|
3399
|
+
|
|
3400
|
+
|
|
3401
|
+
def test_worktree_rm_multirepo_refuses_an_orphan_path_record(
|
|
3402
|
+
git, gitproject, project
|
|
3403
|
+
):
|
|
3404
|
+
workarea = _base()
|
|
3405
|
+
_orphan(git, gitproject, project, workarea, "../wt-o")
|
|
3406
|
+
before = _repo_state(git)
|
|
3407
|
+
|
|
3408
|
+
with pytest.raises(git_project.GitProjectError) as error:
|
|
3409
|
+
command_worktree_rm(
|
|
3410
|
+
git, gitproject, project, _rm_clargs("wt-o", multirepo="tools")
|
|
3411
|
+
)
|
|
3412
|
+
|
|
3413
|
+
assert "git-project has no record of worktree wt-o" in error.value.message
|
|
3414
|
+
assert _repo_state(git) == before
|
|
3415
|
+
|
|
3416
|
+
|
|
3417
|
+
def test_worktree_rm_removes_every_orphan_path_record(
|
|
3418
|
+
git, gitproject, project, capsys
|
|
3419
|
+
):
|
|
3420
|
+
workarea = _base()
|
|
3421
|
+
path = _orphan(git, gitproject, project, workarea, "../wt-o")
|
|
3422
|
+
other = str(workarea / "wt-o-old")
|
|
3423
|
+
git.config.set_item(f"project.worktreepath.{other}", "worktree", "wt-o")
|
|
3424
|
+
assert _path_records(git) == {path: "wt-o", other: "wt-o"}
|
|
3425
|
+
|
|
3426
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs("wt-o"))
|
|
3427
|
+
|
|
3428
|
+
out = capsys.readouterr().out
|
|
3429
|
+
assert (
|
|
3430
|
+
f"Removed the orphan path record project.worktreepath.{path}, and "
|
|
3431
|
+
f"kept the worktree directory {path}"
|
|
3432
|
+
) in out
|
|
3433
|
+
assert f"project.worktreepath.{other}," in out
|
|
3434
|
+
assert _path_records(git) == {}
|
|
3435
|
+
assert (workarea / "wt-o").is_dir()
|
|
3436
|
+
|
|
3437
|
+
# Nothing is left to remove, so a second rm reports no record.
|
|
3438
|
+
with pytest.raises(git_project.GitProjectError) as error:
|
|
3439
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs("wt-o"))
|
|
3440
|
+
assert "git-project has no record of worktree wt-o" in error.value.message
|
|
3441
|
+
|
|
3442
|
+
|
|
3443
|
+
def test_worktree_rm_keeps_a_live_path_record_that_names_an_orphan(
|
|
3444
|
+
git, gitproject, project
|
|
3445
|
+
):
|
|
3446
|
+
workarea = _base()
|
|
3447
|
+
_add(git, gitproject, project, "../wt-live")
|
|
3448
|
+
live = str(workarea / "wt-live")
|
|
3449
|
+
# A hand edit points the live worktree's path record at a gone name.
|
|
3450
|
+
git.config.set_item(f"project.worktreepath.{live}", "worktree", "wt-gone")
|
|
3451
|
+
before = _repo_state(git)
|
|
3452
|
+
|
|
3453
|
+
with pytest.raises(git_project.GitProjectError) as error:
|
|
3454
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs("wt-gone"))
|
|
3455
|
+
|
|
3456
|
+
assert (
|
|
3457
|
+
"git-project has no record of worktree wt-gone" in error.value.message
|
|
3458
|
+
)
|
|
3459
|
+
assert _repo_state(git) == before
|
|
3460
|
+
|
|
3461
|
+
|
|
3462
|
+
def test_worktree_rm_skips_a_multivalued_path_record(git, gitproject, project):
|
|
3463
|
+
workarea = _base()
|
|
3464
|
+
path = str(workarea / "wt-multi")
|
|
3465
|
+
git.config.add_item(f"project.worktreepath.{path}", "worktree", "wt-a")
|
|
3466
|
+
git.config.add_item(f"project.worktreepath.{path}", "worktree", "wt-b")
|
|
3467
|
+
before = _repo_state(git)
|
|
3468
|
+
|
|
3469
|
+
for name in ("wt-none", "wt-a"):
|
|
3470
|
+
with pytest.raises(git_project.GitProjectError) as error:
|
|
3471
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs(name))
|
|
3472
|
+
assert (
|
|
3473
|
+
f"git-project has no record of worktree {name}"
|
|
3474
|
+
in error.value.message
|
|
3475
|
+
)
|
|
3476
|
+
assert _repo_state(git) == before
|
|
3477
|
+
|
|
3478
|
+
|
|
3479
|
+
def test_worktree_rm_removes_both_records(git, gitproject, project):
|
|
3480
|
+
workarea = _base()
|
|
3481
|
+
_add(git, gitproject, project, "../wt-a")
|
|
3482
|
+
assert _path_records(git) == {str(workarea / "wt-a"): "wt-a"}
|
|
3483
|
+
|
|
3484
|
+
command_worktree_rm(git, gitproject, project, _rm_clargs("wt-a"))
|
|
3485
|
+
|
|
3486
|
+
assert _record(git, "wt-a") == {}
|
|
3487
|
+
assert _path_records(git) == {}
|
|
3488
|
+
assert not (workarea / "wt-a").exists()
|
|
3489
|
+
|
|
3490
|
+
|
|
3298
3491
|
def _tag(git, name, committish):
|
|
3299
3492
|
repo = pygit2.Repository(git.get_git_common_dir())
|
|
3300
3493
|
repo.create_reference(
|
|
@@ -3339,3 +3532,28 @@ def test_worktree_rm_check_changes_nothing(git, gitproject, project):
|
|
|
3339
3532
|
)
|
|
3340
3533
|
|
|
3341
3534
|
assert _repo_state(git) == before
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
def test_worktree_menu_hints(git, git_project_runner, script_runner):
|
|
3538
|
+
workarea = git.get_working_copy_root()
|
|
3539
|
+
os.chdir(workarea)
|
|
3540
|
+
git_project_runner.chdir(workarea)
|
|
3541
|
+
|
|
3542
|
+
git_project_runner.run(
|
|
3543
|
+
".*", "", "worktree", "add", "../user/test_hints", "master"
|
|
3544
|
+
)
|
|
3545
|
+
|
|
3546
|
+
def menu(*args):
|
|
3547
|
+
result = script_runner.run(
|
|
3548
|
+
["git-project", *args, "--menu=json"], cwd=workarea
|
|
3549
|
+
)
|
|
3550
|
+
assert result.success
|
|
3551
|
+
return json.loads(result.stdout)
|
|
3552
|
+
|
|
3553
|
+
[path, committish] = menu("worktree", "add")["positionals"]
|
|
3554
|
+
assert path["complete"] == "directory"
|
|
3555
|
+
assert committish["complete"] == "committish"
|
|
3556
|
+
|
|
3557
|
+
[name] = menu("worktree", "rm")["positionals"]
|
|
3558
|
+
assert name["complete"] == "worktree"
|
|
3559
|
+
assert name["candidates"] == ["test_hints"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|