@harryisfish/gitt 1.6.4 → 1.6.6

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.
@@ -23,13 +23,19 @@ async function cleanDeletedBranches(options = {}) {
23
23
  // Phase 1: Discovery
24
24
  const discoveryTasks = new listr2_1.Listr([
25
25
  {
26
- title: 'Fetch main from remote',
26
+ title: 'Fetch and 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
+ // Fetch main branch first to avoid conflicts
32
33
  await git.fetch(['origin', mainBranch]);
34
+ // Switch to main branch if not already on it
35
+ if (ctx.currentBranch !== mainBranch) {
36
+ await git.checkout(mainBranch);
37
+ await git.pull();
38
+ }
33
39
  }
34
40
  },
35
41
  {
@@ -129,18 +135,6 @@ async function cleanDeletedBranches(options = {}) {
129
135
  state.deletedBranches.forEach(b => console.log(` - ${b.name} (${b.reason})`));
130
136
  return;
131
137
  }
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
138
  // Phase 3: Execution
145
139
  const deleteTasks = new listr2_1.Listr([
146
140
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harryisfish/gitt",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "A command-line tool to help you manage Git repositories and remote repositories, such as keeping in sync, pushing, pulling, etc.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {