easy-worktree 0.0.3__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.
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/PKG-INFO +6 -6
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/README.md +5 -5
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/README_ja.md +5 -5
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/easy_worktree/__init__.py +106 -53
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/pyproject.toml +1 -1
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/.gitignore +0 -0
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/.python-version +0 -0
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/DEPLOY.md +0 -0
- {easy_worktree-0.0.3 → easy_worktree-0.0.5}/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easy-worktree
|
|
3
|
-
Version: 0.0.
|
|
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
|
|
@@ -184,11 +184,11 @@ wt clean --all # Remove all clean worktrees without confirmation
|
|
|
184
184
|
Create symbolic link shortcuts to frequently used worktrees.
|
|
185
185
|
|
|
186
186
|
```bash
|
|
187
|
-
wt alias current feature-123
|
|
188
|
-
wt alias dev feature-xyz
|
|
189
|
-
wt alias
|
|
190
|
-
wt alias --list
|
|
191
|
-
wt alias --remove current
|
|
187
|
+
wt alias current feature-123 # Create alias named 'current'
|
|
188
|
+
wt alias dev feature-xyz # Create alias named 'dev'
|
|
189
|
+
wt alias current hoge3 # Automatically override existing alias
|
|
190
|
+
wt alias --list # List all aliases
|
|
191
|
+
wt alias --remove current # Remove an alias
|
|
192
192
|
```
|
|
193
193
|
|
|
194
194
|
### Check status of all worktrees
|
|
@@ -163,11 +163,11 @@ wt clean --all # Remove all clean worktrees without confirmation
|
|
|
163
163
|
Create symbolic link shortcuts to frequently used worktrees.
|
|
164
164
|
|
|
165
165
|
```bash
|
|
166
|
-
wt alias current feature-123
|
|
167
|
-
wt alias dev feature-xyz
|
|
168
|
-
wt alias
|
|
169
|
-
wt alias --list
|
|
170
|
-
wt alias --remove current
|
|
166
|
+
wt alias current feature-123 # Create alias named 'current'
|
|
167
|
+
wt alias dev feature-xyz # Create alias named 'dev'
|
|
168
|
+
wt alias current hoge3 # Automatically override existing alias
|
|
169
|
+
wt alias --list # List all aliases
|
|
170
|
+
wt alias --remove current # Remove an alias
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
### Check status of all worktrees
|
|
@@ -161,11 +161,11 @@ wt clean --all # すべての clean worktree を削除(確認な
|
|
|
161
161
|
よく使う worktree にシンボリックリンクでショートカットを作成できます。
|
|
162
162
|
|
|
163
163
|
```bash
|
|
164
|
-
wt alias current feature-123
|
|
165
|
-
wt alias dev feature-xyz
|
|
166
|
-
wt alias
|
|
167
|
-
wt alias --list
|
|
168
|
-
wt alias --remove current
|
|
164
|
+
wt alias current feature-123 # current という名前でエイリアス作成
|
|
165
|
+
wt alias dev feature-xyz # dev という名前でエイリアス作成
|
|
166
|
+
wt alias current hoge3 # 既存のエイリアスを自動的に上書き
|
|
167
|
+
wt alias --list # エイリアス一覧を表示
|
|
168
|
+
wt alias --remove current # エイリアスを削除
|
|
169
169
|
```
|
|
170
170
|
|
|
171
171
|
### 全 worktree の状態を確認
|
|
@@ -128,9 +128,9 @@ MESSAGES = {
|
|
|
128
128
|
'en': 'Usage: wt alias <name> <worktree> | wt alias --list | wt alias --remove <name>',
|
|
129
129
|
'ja': '使用方法: wt alias <名前> <worktree> | wt alias --list | wt alias --remove <名前>'
|
|
130
130
|
},
|
|
131
|
-
'
|
|
132
|
-
'en': '
|
|
133
|
-
'ja': '
|
|
131
|
+
'alias_updated': {
|
|
132
|
+
'en': 'Updated alias: {} -> {}',
|
|
133
|
+
'ja': 'エイリアスを更新しました: {} -> {}'
|
|
134
134
|
},
|
|
135
135
|
'no_clean_targets': {
|
|
136
136
|
'en': 'No worktrees to clean',
|
|
@@ -454,56 +454,104 @@ def cmd_add(args: list[str]):
|
|
|
454
454
|
check=False
|
|
455
455
|
)
|
|
456
456
|
else:
|
|
457
|
-
#
|
|
457
|
+
# ブランチ名として work_name を使用
|
|
458
458
|
branch_name = work_name
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
|
|
460
|
+
# ローカルまたはリモートにブランチが既に存在するかチェック
|
|
461
|
+
check_local = run_command(
|
|
462
|
+
["git", "rev-parse", "--verify", branch_name],
|
|
463
|
+
cwd=base_dir,
|
|
464
|
+
check=False
|
|
465
|
+
)
|
|
466
|
+
check_remote = run_command(
|
|
467
|
+
["git", "rev-parse", "--verify", f"origin/{branch_name}"],
|
|
462
468
|
cwd=base_dir,
|
|
463
469
|
check=False
|
|
464
470
|
)
|
|
465
471
|
|
|
466
|
-
if
|
|
467
|
-
|
|
472
|
+
if check_local.returncode == 0 or check_remote.returncode == 0:
|
|
473
|
+
# 既存ブランチを使用
|
|
474
|
+
if check_remote.returncode == 0:
|
|
475
|
+
# リモートブランチが存在する場合
|
|
476
|
+
print(msg('creating_worktree', worktree_path))
|
|
477
|
+
result = run_command(
|
|
478
|
+
["git", "worktree", "add", str(worktree_path), f"origin/{branch_name}"],
|
|
479
|
+
cwd=base_dir,
|
|
480
|
+
check=False
|
|
481
|
+
)
|
|
482
|
+
else:
|
|
483
|
+
# ローカルブランチのみ存在する場合
|
|
484
|
+
print(msg('creating_worktree', worktree_path))
|
|
485
|
+
result = run_command(
|
|
486
|
+
["git", "worktree", "add", str(worktree_path), branch_name],
|
|
487
|
+
cwd=base_dir,
|
|
488
|
+
check=False
|
|
489
|
+
)
|
|
468
490
|
else:
|
|
469
|
-
#
|
|
470
|
-
|
|
471
|
-
|
|
491
|
+
# 新しいブランチを作成
|
|
492
|
+
# デフォルトブランチを探す(origin/main または origin/master)
|
|
493
|
+
result = run_command(
|
|
494
|
+
["git", "symbolic-ref", "refs/remotes/origin/HEAD", "--short"],
|
|
472
495
|
cwd=base_dir,
|
|
473
496
|
check=False
|
|
474
497
|
)
|
|
475
|
-
|
|
476
|
-
|
|
498
|
+
|
|
499
|
+
if result.returncode == 0 and result.stdout.strip():
|
|
500
|
+
base_branch = result.stdout.strip()
|
|
501
|
+
else:
|
|
502
|
+
# symbolic-ref が失敗した場合は手動でチェック
|
|
503
|
+
result_main = run_command(
|
|
504
|
+
["git", "rev-parse", "--verify", "origin/main"],
|
|
505
|
+
cwd=base_dir,
|
|
506
|
+
check=False
|
|
507
|
+
)
|
|
508
|
+
result_master = run_command(
|
|
509
|
+
["git", "rev-parse", "--verify", "origin/master"],
|
|
510
|
+
cwd=base_dir,
|
|
511
|
+
check=False
|
|
512
|
+
)
|
|
513
|
+
|
|
514
|
+
if result_main.returncode == 0:
|
|
515
|
+
base_branch = "origin/main"
|
|
516
|
+
elif result_master.returncode == 0:
|
|
517
|
+
base_branch = "origin/master"
|
|
518
|
+
else:
|
|
519
|
+
print(msg('error', msg('default_branch_not_found')), file=sys.stderr)
|
|
520
|
+
sys.exit(1)
|
|
521
|
+
|
|
522
|
+
print(msg('creating_branch', base_branch, work_name))
|
|
523
|
+
result = run_command(
|
|
524
|
+
["git", "worktree", "add", "-b", work_name, str(worktree_path), base_branch],
|
|
477
525
|
cwd=base_dir,
|
|
478
526
|
check=False
|
|
479
527
|
)
|
|
480
528
|
|
|
481
|
-
if result_main.returncode == 0:
|
|
482
|
-
base_branch = "origin/main"
|
|
483
|
-
elif result_master.returncode == 0:
|
|
484
|
-
base_branch = "origin/master"
|
|
485
|
-
else:
|
|
486
|
-
print(msg('error', msg('default_branch_not_found')), file=sys.stderr)
|
|
487
|
-
sys.exit(1)
|
|
488
|
-
|
|
489
|
-
print(msg('creating_branch', base_branch, work_name))
|
|
490
|
-
result = run_command(
|
|
491
|
-
["git", "worktree", "add", "-b", work_name, str(worktree_path), base_branch],
|
|
492
|
-
cwd=base_dir,
|
|
493
|
-
check=False
|
|
494
|
-
)
|
|
495
|
-
|
|
496
529
|
if result.returncode == 0:
|
|
497
530
|
print(msg('completed_worktree', worktree_path))
|
|
498
531
|
|
|
499
532
|
# エイリアスを作成
|
|
500
533
|
if alias_name:
|
|
501
534
|
alias_path = base_dir.parent / alias_name
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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))
|
|
505
554
|
else:
|
|
506
|
-
alias_path.symlink_to(worktree_path, target_is_directory=True)
|
|
507
555
|
print(msg('alias_created', alias_name, work_name))
|
|
508
556
|
|
|
509
557
|
# post-add hook を実行
|
|
@@ -676,6 +724,14 @@ def cmd_clean(args: list[str]):
|
|
|
676
724
|
# worktree 情報を取得
|
|
677
725
|
worktrees = get_worktree_info(base_dir)
|
|
678
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
|
+
|
|
679
735
|
# 削除対象を抽出(_baseは除外)
|
|
680
736
|
targets = []
|
|
681
737
|
now = datetime.now()
|
|
@@ -687,6 +743,10 @@ def cmd_clean(args: list[str]):
|
|
|
687
743
|
if path.name == '_base':
|
|
688
744
|
continue
|
|
689
745
|
|
|
746
|
+
# エイリアスで使われている worktree は除外
|
|
747
|
+
if path in aliased_worktrees:
|
|
748
|
+
continue
|
|
749
|
+
|
|
690
750
|
# clean状態のものだけが対象
|
|
691
751
|
if not wt.get('is_clean'):
|
|
692
752
|
continue
|
|
@@ -789,11 +849,6 @@ def cmd_alias(args: list[str]):
|
|
|
789
849
|
print(msg('alias_removed', alias_name))
|
|
790
850
|
return
|
|
791
851
|
|
|
792
|
-
# --override オプションをチェック
|
|
793
|
-
override = '--override' in args
|
|
794
|
-
if override:
|
|
795
|
-
args.remove('--override')
|
|
796
|
-
|
|
797
852
|
# エイリアス作成
|
|
798
853
|
if len(args) < 2:
|
|
799
854
|
print(msg('usage_alias'), file=sys.stderr)
|
|
@@ -810,19 +865,19 @@ def cmd_alias(args: list[str]):
|
|
|
810
865
|
print(msg('error', f'Worktree not found: {worktree_name}'), file=sys.stderr)
|
|
811
866
|
sys.exit(1)
|
|
812
867
|
|
|
813
|
-
#
|
|
868
|
+
# エイリアスがすでに存在する場合は上書き
|
|
814
869
|
if alias_path.exists():
|
|
815
|
-
if not override:
|
|
816
|
-
print(msg('error', msg('already_exists', alias_name)), file=sys.stderr)
|
|
817
|
-
print(msg('alias_exists_suggestion', alias_name, worktree_name), file=sys.stderr)
|
|
818
|
-
sys.exit(1)
|
|
819
|
-
# --override が指定されている場合は既存のエイリアスを削除
|
|
820
870
|
if alias_path.is_symlink():
|
|
821
871
|
alias_path.unlink()
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
872
|
+
alias_path.symlink_to(worktree_path, target_is_directory=True)
|
|
873
|
+
print(msg('alias_updated', alias_name, worktree_name))
|
|
874
|
+
else:
|
|
875
|
+
print(msg('error', f'{alias_name} exists but is not a symlink'), file=sys.stderr)
|
|
876
|
+
sys.exit(1)
|
|
877
|
+
else:
|
|
878
|
+
# シンボリックリンクを作成
|
|
879
|
+
alias_path.symlink_to(worktree_path, target_is_directory=True)
|
|
880
|
+
print(msg('alias_created', alias_name, worktree_name))
|
|
826
881
|
|
|
827
882
|
|
|
828
883
|
def cmd_status(args: list[str]):
|
|
@@ -897,8 +952,7 @@ def show_help():
|
|
|
897
952
|
print(" rm <作業名> - worktree を削除")
|
|
898
953
|
print(" remove <作業名> - worktree を削除")
|
|
899
954
|
print(" clean [--dry-run] [--days N] - 未使用の worktree を削除")
|
|
900
|
-
print(" alias <名前> <worktree> - worktree
|
|
901
|
-
print(" alias --override <名前> <worktree> - エイリアスを上書き")
|
|
955
|
+
print(" alias <名前> <worktree> - worktree のエイリアスを作成/更新")
|
|
902
956
|
print(" alias --list - エイリアス一覧を表示")
|
|
903
957
|
print(" alias --remove <名前> - エイリアスを削除")
|
|
904
958
|
print(" status [--dirty] [--short] - 全 worktree の状態を表示")
|
|
@@ -921,8 +975,7 @@ def show_help():
|
|
|
921
975
|
print(" rm <work_name> - Remove a worktree")
|
|
922
976
|
print(" remove <work_name> - Remove a worktree")
|
|
923
977
|
print(" clean [--dry-run] [--days N] - Remove unused worktrees")
|
|
924
|
-
print(" alias <name> <worktree> - Create an alias for a worktree")
|
|
925
|
-
print(" alias --override <name> <worktree> - Override an existing alias")
|
|
978
|
+
print(" alias <name> <worktree> - Create or update an alias for a worktree")
|
|
926
979
|
print(" alias --list - List aliases")
|
|
927
980
|
print(" alias --remove <name> - Remove an alias")
|
|
928
981
|
print(" status [--dirty] [--short] - Show status of all worktrees")
|
|
@@ -935,7 +988,7 @@ def show_help():
|
|
|
935
988
|
|
|
936
989
|
def show_version():
|
|
937
990
|
"""Show version information"""
|
|
938
|
-
print("easy-worktree version 0.0.
|
|
991
|
+
print("easy-worktree version 0.0.5")
|
|
939
992
|
|
|
940
993
|
|
|
941
994
|
def main():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|