easy-worktree 0.1.4__tar.gz → 0.1.5__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.
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/PKG-INFO +1 -1
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/easy_worktree/__init__.py +29 -5
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/pyproject.toml +1 -1
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/tests/test_integration.py +54 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/uv.lock +1 -1
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/.gitignore +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/.python-version +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/DEPLOY.md +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/GEMINI.md +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/LICENSE +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/README.md +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/README_ja.md +0 -0
- {easy_worktree-0.1.4 → easy_worktree-0.1.5}/hero.png +0 -0
|
@@ -28,8 +28,8 @@ MESSAGES = {
|
|
|
28
28
|
"ja": "使用方法: wt clone <repository_url>",
|
|
29
29
|
},
|
|
30
30
|
"usage_add": {
|
|
31
|
-
"en": "Usage: wt add (ad) <work_name> [<base_branch>]",
|
|
32
|
-
"ja": "使用方法: wt add (ad) <作業名> [<base_branch>]",
|
|
31
|
+
"en": "Usage: wt add (ad) <work_name> [<base_branch>] [--no-setup] [--select]",
|
|
32
|
+
"ja": "使用方法: wt add (ad) <作業名> [<base_branch>] [--no-setup] [--select]",
|
|
33
33
|
},
|
|
34
34
|
"usage_rm": {"en": "Usage: wt rm <work_name>", "ja": "使用方法: wt rm <作業名>"},
|
|
35
35
|
"base_not_found": {
|
|
@@ -855,7 +855,7 @@ def add_worktree(
|
|
|
855
855
|
|
|
856
856
|
|
|
857
857
|
def cmd_add(args: list[str]):
|
|
858
|
-
"""wt add <work_name> [<base_branch>] [--
|
|
858
|
+
"""wt add <work_name> [<base_branch>] [--no-setup] [--select] - Add a worktree"""
|
|
859
859
|
if len(args) < 1:
|
|
860
860
|
print(msg("usage_add"), file=sys.stderr)
|
|
861
861
|
sys.exit(1)
|
|
@@ -863,10 +863,13 @@ def cmd_add(args: list[str]):
|
|
|
863
863
|
# parse options
|
|
864
864
|
clean_args = []
|
|
865
865
|
skip_setup = False
|
|
866
|
+
select = False
|
|
866
867
|
|
|
867
868
|
for arg in args:
|
|
868
|
-
if arg
|
|
869
|
+
if arg in ["--skip-setup", "--no-setup"]:
|
|
869
870
|
skip_setup = True
|
|
871
|
+
elif arg == "--select":
|
|
872
|
+
select = True
|
|
870
873
|
else:
|
|
871
874
|
clean_args.append(arg)
|
|
872
875
|
|
|
@@ -877,7 +880,28 @@ def cmd_add(args: list[str]):
|
|
|
877
880
|
work_name = clean_args[0]
|
|
878
881
|
branch_to_use = clean_args[1] if len(clean_args) >= 2 else None
|
|
879
882
|
|
|
880
|
-
|
|
883
|
+
base_dir = find_base_dir()
|
|
884
|
+
wt_path = add_worktree(work_name, branch_to_use=branch_to_use, skip_setup=skip_setup, base_dir=base_dir)
|
|
885
|
+
|
|
886
|
+
if select and wt_path:
|
|
887
|
+
wt_dir = base_dir / ".wt"
|
|
888
|
+
# Ensure .wt directory and its management files exists
|
|
889
|
+
create_hook_template(base_dir)
|
|
890
|
+
last_sel_file = wt_dir / "last_selection"
|
|
891
|
+
|
|
892
|
+
# Get current selection name
|
|
893
|
+
current_sel = os.environ.get("WT_SESSION_NAME")
|
|
894
|
+
if not current_sel:
|
|
895
|
+
cwd = Path.cwd().resolve()
|
|
896
|
+
worktrees = get_worktree_info(base_dir)
|
|
897
|
+
resolved_base = base_dir.resolve()
|
|
898
|
+
for wt in worktrees:
|
|
899
|
+
p = Path(wt["path"]).resolve()
|
|
900
|
+
if cwd == p or cwd.is_relative_to(p):
|
|
901
|
+
current_sel = "main" if p == resolved_base else p.name
|
|
902
|
+
break
|
|
903
|
+
|
|
904
|
+
switch_selection(work_name, base_dir, current_sel, last_sel_file)
|
|
881
905
|
|
|
882
906
|
|
|
883
907
|
def cmd_stash(args: list[str]):
|
|
@@ -762,5 +762,59 @@ touch hook_ran.txt
|
|
|
762
762
|
self.assertTrue(wt_gitignore.exists())
|
|
763
763
|
self.assertIn("last_selection", wt_gitignore.read_text())
|
|
764
764
|
|
|
765
|
+
def test_20_add_no_setup(self):
|
|
766
|
+
"""Test 'wt add --no-setup' (alias for --skip-setup)"""
|
|
767
|
+
project_dir = self.test_dir / "no-setup-test"
|
|
768
|
+
if project_dir.exists():
|
|
769
|
+
shutil.rmtree(project_dir)
|
|
770
|
+
project_dir.mkdir()
|
|
771
|
+
subprocess.run(["git", "init"], cwd=project_dir)
|
|
772
|
+
(project_dir / "README.md").write_text("Hello")
|
|
773
|
+
subprocess.run(["git", "add", "."], cwd=project_dir)
|
|
774
|
+
subprocess.run(["git", "commit", "-m", "Initial commit"], cwd=project_dir)
|
|
775
|
+
self.run_wt(["init"], cwd=project_dir)
|
|
776
|
+
|
|
777
|
+
# Config setup files
|
|
778
|
+
config_file = project_dir / ".wt" / "config.toml"
|
|
779
|
+
with open(config_file, "r") as f:
|
|
780
|
+
config = toml.load(f)
|
|
781
|
+
config["setup_files"] = ["setup_me.txt"]
|
|
782
|
+
with open(config_file, "w") as f:
|
|
783
|
+
toml.dump(config, f)
|
|
784
|
+
|
|
785
|
+
# Create the setup file
|
|
786
|
+
(project_dir / "setup_me.txt").write_text("setup content")
|
|
787
|
+
|
|
788
|
+
print("\nTesting wt add --no-setup...")
|
|
789
|
+
self.run_wt(["add", "wt-no-setup", "--no-setup"], cwd=project_dir)
|
|
790
|
+
|
|
791
|
+
wt_dir = project_dir / ".worktrees" / "wt-no-setup"
|
|
792
|
+
|
|
793
|
+
# Verify setup file NOT copied
|
|
794
|
+
self.assertFalse((wt_dir / "setup_me.txt").exists(), "Setup file should NOT be copied with --no-setup")
|
|
795
|
+
|
|
796
|
+
def test_21_add_select(self):
|
|
797
|
+
"""Test 'wt add --select' (auto switch)"""
|
|
798
|
+
# Note: In non-TTY environment, switch_selection prints the absolute path.
|
|
799
|
+
project_dir = self.test_dir / "add-select-test"
|
|
800
|
+
if project_dir.exists():
|
|
801
|
+
shutil.rmtree(project_dir)
|
|
802
|
+
project_dir.mkdir()
|
|
803
|
+
subprocess.run(["git", "init"], cwd=project_dir)
|
|
804
|
+
(project_dir / "README.md").write_text("Hello")
|
|
805
|
+
subprocess.run(["git", "add", "."], cwd=project_dir)
|
|
806
|
+
subprocess.run(["git", "commit", "-m", "Initial commit"], cwd=project_dir)
|
|
807
|
+
self.run_wt(["init"], cwd=project_dir)
|
|
808
|
+
|
|
809
|
+
print("\nTesting wt add --select...")
|
|
810
|
+
# Since this is non-TTY, it should output the path
|
|
811
|
+
result = self.run_wt(["add", "wt-select", "--select"], cwd=project_dir)
|
|
812
|
+
|
|
813
|
+
self.assertEqual(result.returncode, 0)
|
|
814
|
+
|
|
815
|
+
# Check if output contains the path to the new worktree
|
|
816
|
+
expected_path = str((project_dir / ".worktrees" / "wt-select").absolute())
|
|
817
|
+
self.assertIn(expected_path, result.stdout.strip())
|
|
818
|
+
|
|
765
819
|
if __name__ == "__main__":
|
|
766
820
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|