easy-worktree 0.0.4__tar.gz → 0.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: easy-worktree
3
- Version: 0.0.4
3
+ Version: 0.0.5
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
@@ -532,16 +532,26 @@ def cmd_add(args: list[str]):
532
532
  # エイリアスを作成
533
533
  if alias_name:
534
534
  alias_path = base_dir.parent / alias_name
535
- if alias_path.exists():
536
- # 既存のエイリアスを削除して上書き
537
- if alias_path.is_symlink():
538
- alias_path.unlink()
539
- alias_path.symlink_to(worktree_path, target_is_directory=True)
540
- print(msg('alias_updated', alias_name, work_name))
541
- else:
542
- print(msg('error', f'{alias_name} exists but is not a symlink'), file=sys.stderr)
535
+
536
+ # 既存かどうかをチェック
537
+ is_updating = alias_path.is_symlink()
538
+
539
+ # 既存のシンボリックリンクを削除
540
+ if alias_path.is_symlink():
541
+ alias_path.unlink()
542
+ elif alias_path.exists():
543
+ # シンボリックリンクではないファイル/ディレクトリが存在
544
+ print(msg('error', f'{alias_name} exists but is not a symlink'), file=sys.stderr)
545
+ # post-add hook を実行
546
+ run_post_add_hook(worktree_path, work_name, base_dir, branch_name)
547
+ sys.exit(0) # worktree は作成できたので正常終了
548
+
549
+ # シンボリックリンクを作成
550
+ alias_path.symlink_to(worktree_path, target_is_directory=True)
551
+
552
+ if is_updating:
553
+ print(msg('alias_updated', alias_name, work_name))
543
554
  else:
544
- alias_path.symlink_to(worktree_path, target_is_directory=True)
545
555
  print(msg('alias_created', alias_name, work_name))
546
556
 
547
557
  # post-add hook を実行
@@ -714,6 +724,14 @@ def cmd_clean(args: list[str]):
714
724
  # worktree 情報を取得
715
725
  worktrees = get_worktree_info(base_dir)
716
726
 
727
+ # エイリアスで使われている worktree を取得
728
+ parent_dir = base_dir.parent
729
+ aliased_worktrees = set()
730
+ for item in parent_dir.iterdir():
731
+ if item.is_symlink() and item.name != '_base':
732
+ target = item.resolve()
733
+ aliased_worktrees.add(target)
734
+
717
735
  # 削除対象を抽出(_baseは除外)
718
736
  targets = []
719
737
  now = datetime.now()
@@ -725,6 +743,10 @@ def cmd_clean(args: list[str]):
725
743
  if path.name == '_base':
726
744
  continue
727
745
 
746
+ # エイリアスで使われている worktree は除外
747
+ if path in aliased_worktrees:
748
+ continue
749
+
728
750
  # clean状態のものだけが対象
729
751
  if not wt.get('is_clean'):
730
752
  continue
@@ -966,7 +988,7 @@ def show_help():
966
988
 
967
989
  def show_version():
968
990
  """Show version information"""
969
- print("easy-worktree version 0.0.4")
991
+ print("easy-worktree version 0.0.5")
970
992
 
971
993
 
972
994
  def main():
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "easy-worktree"
7
- version = "0.0.4"
7
+ version = "0.0.5"
8
8
  description = "Git worktree を簡単に管理するための CLI ツール"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
File without changes
File without changes
File without changes
File without changes