@saeed42/worktree-worker 1.4.1 → 1.5.0
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/main.js +17 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1058,13 +1058,24 @@ var WorktreeService = class {
|
|
|
1058
1058
|
await gitService.pruneWorktrees(baseRepoDir);
|
|
1059
1059
|
const localBranchExists = await gitService.branchExists(branchName, baseRepoDir);
|
|
1060
1060
|
const remoteBranchExists = await gitService.branchExists(`origin/${branchName}`, baseRepoDir);
|
|
1061
|
+
const createWorktreeWithCreds = async (operation) => {
|
|
1062
|
+
if (options.githubToken) {
|
|
1063
|
+
await gitService.withCredentials(options.githubToken, operation);
|
|
1064
|
+
} else {
|
|
1065
|
+
await operation();
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1061
1068
|
if (localBranchExists) {
|
|
1062
1069
|
log.info("Creating worktree from existing local branch", { branchName });
|
|
1063
|
-
await
|
|
1070
|
+
await createWorktreeWithCreds(async () => {
|
|
1071
|
+
await gitService.execOrThrow(["worktree", "add", worktreePath, branchName], baseRepoDir);
|
|
1072
|
+
});
|
|
1064
1073
|
} else if (remoteBranchExists) {
|
|
1065
1074
|
log.info("Creating worktree from remote branch", { branchName });
|
|
1066
|
-
await
|
|
1067
|
-
|
|
1075
|
+
await createWorktreeWithCreds(async () => {
|
|
1076
|
+
await gitService.exec(["fetch", "origin", `${branchName}:${branchName}`], baseRepoDir);
|
|
1077
|
+
await gitService.execOrThrow(["worktree", "add", worktreePath, branchName], baseRepoDir);
|
|
1078
|
+
});
|
|
1068
1079
|
} else {
|
|
1069
1080
|
let baseRef = `origin/${baseBranch}`;
|
|
1070
1081
|
const baseBranchExistsOnRemote = await gitService.branchExists(baseRef, baseRepoDir);
|
|
@@ -1100,7 +1111,9 @@ var WorktreeService = class {
|
|
|
1100
1111
|
}
|
|
1101
1112
|
}
|
|
1102
1113
|
log.info("Creating worktree with new branch from base", { baseRef, branchName });
|
|
1103
|
-
await
|
|
1114
|
+
await createWorktreeWithCreds(async () => {
|
|
1115
|
+
await gitService.addWorktreeWithNewBranch(worktreePath, branchName, baseRef, baseRepoDir);
|
|
1116
|
+
});
|
|
1104
1117
|
}
|
|
1105
1118
|
await gitService.exec(["config", "--local", "user.name", "origin-agent[bot]"], worktreePath).catch(() => {
|
|
1106
1119
|
});
|