@harryisfish/gitt 1.6.4 → 1.6.5
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 +12 -14
- package/package.json +1 -1
package/dist/commands/clean.js
CHANGED
|
@@ -23,13 +23,23 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
23
23
|
// Phase 1: Discovery
|
|
24
24
|
const discoveryTasks = new listr2_1.Listr([
|
|
25
25
|
{
|
|
26
|
-
title: '
|
|
26
|
+
title: 'Switch to main branch',
|
|
27
27
|
task: async (ctx) => {
|
|
28
28
|
const mainBranch = await (0, git_1.getMainBranch)();
|
|
29
29
|
ctx.mainBranch = mainBranch;
|
|
30
30
|
const branchInfo = await git.branchLocal();
|
|
31
31
|
ctx.currentBranch = branchInfo.current;
|
|
32
|
-
|
|
32
|
+
// Always switch to main branch first
|
|
33
|
+
if (ctx.currentBranch !== mainBranch) {
|
|
34
|
+
await git.checkout(mainBranch);
|
|
35
|
+
await git.pull();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Fetch from remote',
|
|
41
|
+
task: async (ctx) => {
|
|
42
|
+
await git.fetch(['origin', ctx.mainBranch]);
|
|
33
43
|
}
|
|
34
44
|
},
|
|
35
45
|
{
|
|
@@ -129,18 +139,6 @@ async function cleanDeletedBranches(options = {}) {
|
|
|
129
139
|
state.deletedBranches.forEach(b => console.log(` - ${b.name} (${b.reason})`));
|
|
130
140
|
return;
|
|
131
141
|
}
|
|
132
|
-
// Switch to main branch if current branch will be deleted
|
|
133
|
-
const willDeleteCurrent = state.deletedBranches.some(b => b.name === state.currentBranch);
|
|
134
|
-
if (willDeleteCurrent) {
|
|
135
|
-
try {
|
|
136
|
-
await git.checkout(state.mainBranch);
|
|
137
|
-
await git.pull();
|
|
138
|
-
console.log(`Switched to ${state.mainBranch} and synced with remote`);
|
|
139
|
-
}
|
|
140
|
-
catch (e) {
|
|
141
|
-
throw new errors_1.GitError(`Cannot switch to ${state.mainBranch}. Current branch "${state.currentBranch}" will be deleted but checkout failed: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
142
|
// Phase 3: Execution
|
|
145
143
|
const deleteTasks = new listr2_1.Listr([
|
|
146
144
|
{
|
package/package.json
CHANGED