@harryisfish/gitt 1.6.7 → 1.6.8
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.
- package/dist/commands/clean.js +18 -18
- package/package.json +1 -1
package/dist/commands/clean.js
CHANGED
|
@@ -18,7 +18,8 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
18
18
|
const state = {
|
|
19
19
|
mainBranch: '',
|
|
20
20
|
currentBranch: '',
|
|
21
|
-
deletedBranches: []
|
|
21
|
+
deletedBranches: [],
|
|
22
|
+
isStaleMode: options.stale || false
|
|
22
23
|
};
|
|
23
24
|
// Phase 1: Discovery
|
|
24
25
|
const discoveryTasks = new listr2_1.Listr([
|
|
@@ -84,12 +85,19 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
84
85
|
}
|
|
85
86
|
// Filter out worktree branches
|
|
86
87
|
candidates = candidates.filter(c => !worktreeBranches.includes(c.name));
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
// For stale mode, check merge status; for gone mode, skip (PR completed = safe to delete)
|
|
89
|
+
if (options.stale) {
|
|
90
|
+
const branchesWithStatus = await Promise.all(candidates.map(async (c) => {
|
|
91
|
+
const isMerged = await (0, git_1.isBranchMerged)(c.name, ctx.mainBranch);
|
|
92
|
+
return { ...c, isMerged };
|
|
93
|
+
}));
|
|
94
|
+
// In stale mode, only auto-delete merged branches
|
|
95
|
+
ctx.deletedBranches = branchesWithStatus.filter(b => b.isMerged);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Gone mode: remote deleted = PR completed, safe to delete all
|
|
99
|
+
ctx.deletedBranches = candidates;
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
103
|
]);
|
|
@@ -102,9 +110,9 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
102
110
|
if (options.interactive) {
|
|
103
111
|
try {
|
|
104
112
|
const choices = state.deletedBranches.map(b => ({
|
|
105
|
-
name: `${b.name} (${b.reason}
|
|
113
|
+
name: `${b.name} (${b.reason})`,
|
|
106
114
|
value: b,
|
|
107
|
-
checked:
|
|
115
|
+
checked: true // All candidates are safe to delete
|
|
108
116
|
}));
|
|
109
117
|
const selected = await (0, prompts_1.checkbox)({
|
|
110
118
|
message: 'Select branches to delete:',
|
|
@@ -117,15 +125,7 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
117
125
|
throw new errors_1.UserCancelError('Operation cancelled');
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
|
-
|
|
121
|
-
// Auto mode: Filter out unmerged branches
|
|
122
|
-
const unmerged = state.deletedBranches.filter(b => !b.isMerged);
|
|
123
|
-
state.deletedBranches = state.deletedBranches.filter(b => b.isMerged);
|
|
124
|
-
if (state.deletedBranches.length === 0 && unmerged.length > 0) {
|
|
125
|
-
(0, errors_1.printSuccess)(`No merged branches to clean up (${unmerged.length} unmerged branch${unmerged.length > 1 ? 'es' : ''} skipped, use -i to review)`);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
128
|
+
// Non-interactive mode: delete all candidates (already filtered in discovery phase)
|
|
129
129
|
if (state.deletedBranches.length === 0) {
|
|
130
130
|
(0, errors_1.printSuccess)('No branches selected for deletion');
|
|
131
131
|
return;
|
package/package.json
CHANGED