easy-worktree 0.1.7__tar.gz → 0.1.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easy-worktree
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Git worktree を簡単に管理するための CLI ツール
5
5
  Project-URL: Homepage, https://github.com/igtm/easy-worktree
6
6
  Project-URL: Repository, https://github.com/igtm/easy-worktree
@@ -872,31 +872,36 @@ def cmd_add(args: list[str]):
872
872
  clean_args = []
873
873
  skip_setup = False
874
874
  select = False
875
+ select_command = None
875
876
 
876
- for arg in args:
877
+ i = 0
878
+ while i < len(args):
879
+ arg = args[i]
877
880
  if arg in ["--skip-setup", "--no-setup"]:
878
881
  skip_setup = True
879
882
  elif arg == "--select":
880
883
  select = True
884
+ if i + 1 < len(args):
885
+ select_command = args[i+1:]
886
+ break # Consume everything after --select as command
881
887
  else:
882
888
  clean_args.append(arg)
883
-
889
+ i += 1
890
+
891
+ # Heuristic: if clean_args is empty but we have select_command,
892
+ # it likely means the user put --select before the work_name.
893
+ if not clean_args and select_command:
894
+ # Take the first one as work_name
895
+ clean_args.append(select_command.pop(0))
896
+ if not select_command:
897
+ select_command = None
898
+
884
899
  if not clean_args:
885
900
  print(msg("usage_add"), file=sys.stderr)
886
901
  sys.exit(1)
887
902
 
888
903
  work_name = clean_args[0]
889
904
  branch_to_use = clean_args[1] if len(clean_args) >= 2 else None
890
-
891
- # --select 以降をコマンドとして扱う
892
- select_command = None
893
- if select:
894
- try:
895
- select_idx = args.index("--select")
896
- if select_idx + 1 < len(args):
897
- select_command = args[select_idx + 1:]
898
- except ValueError:
899
- pass
900
905
 
901
906
  base_dir = find_base_dir()
902
907
  wt_path = add_worktree(work_name, branch_to_use=branch_to_use, skip_setup=skip_setup, base_dir=base_dir)
@@ -2011,7 +2016,7 @@ def show_help():
2011
2016
 
2012
2017
  def show_version():
2013
2018
  """Show version information"""
2014
- print("easy-worktree version 0.1.7")
2019
+ print("easy-worktree version 0.1.8")
2015
2020
 
2016
2021
 
2017
2022
  def main():
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "easy-worktree"
7
- version = "0.1.7"
7
+ version = "0.1.8"
8
8
  description = "Git worktree を簡単に管理するための CLI ツール"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -839,5 +839,25 @@ touch hook_ran.txt
839
839
  wt_dir = project_dir / ".worktrees" / "wt-run"
840
840
  self.assertTrue((wt_dir / "run_tested.txt").exists(), "Command 'touch' failed to create file in worktree")
841
841
 
842
+ def test_23_add_select_parser_fix(self):
843
+ """Test 'wt add --select name cmd' (bug fix for parser)"""
844
+ project_dir = self.test_dir / "add-select-parser-test"
845
+ if project_dir.exists():
846
+ shutil.rmtree(project_dir)
847
+ project_dir.mkdir()
848
+ subprocess.run(["git", "init"], cwd=project_dir)
849
+ (project_dir / "README.md").write_text("Hello")
850
+ subprocess.run(["git", "add", "."], cwd=project_dir)
851
+ subprocess.run(["git", "commit", "-m", "Initial commit"], cwd=project_dir)
852
+ self.run_wt(["init"], cwd=project_dir)
853
+
854
+ # This should correctly use 'wt-parser-fix' as worktree name and 'touch parser_fixed.txt' as command
855
+ result = self.run_wt(["add", "--select", "wt-parser-fix", "touch", "parser_fixed.txt"], cwd=project_dir)
856
+ self.assertEqual(result.returncode, 0)
857
+
858
+ wt_dir = project_dir / ".worktrees" / "wt-parser-fix"
859
+ self.assertTrue(wt_dir.exists(), "Worktree not created")
860
+ self.assertTrue((wt_dir / "parser_fixed.txt").exists(), "Command failed to run in correct worktree")
861
+
842
862
  if __name__ == "__main__":
843
863
  unittest.main()
@@ -4,7 +4,7 @@ requires-python = ">=3.10"
4
4
 
5
5
  [[package]]
6
6
  name = "easy-worktree"
7
- version = "0.1.6"
7
+ version = "0.1.7"
8
8
  source = { editable = "." }
9
9
  dependencies = [
10
10
  { name = "toml" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes