claude-teammate 0.1.34 → 0.1.35
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/package.json +1 -1
- package/src/commands/worker.js +4 -3
- package/src/github.js +11 -0
- package/src/repo.js +15 -11
package/package.json
CHANGED
package/src/commands/worker.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "../memory.js";
|
|
28
28
|
import {
|
|
29
29
|
commitAndPushRepoChanges,
|
|
30
|
-
|
|
30
|
+
ensureBranchFromDefault,
|
|
31
31
|
hasUsableGitCheckout,
|
|
32
32
|
listMissingRepoPaths,
|
|
33
33
|
parseGitHubRepoUrl,
|
|
@@ -658,12 +658,13 @@ async function processGitHubIssue({ repo, issue, projectRoot, github, githubBotU
|
|
|
658
658
|
return buildGitHubIssueState(detail, githubIssueMemory, "blocked");
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
-
await
|
|
661
|
+
const defaultBranch = await github.getDefaultBranch(githubIssueMemory.repo_url);
|
|
662
|
+
await ensureBranchFromDefault(githubIssueMemory.local_path, nextBranchName, defaultBranch);
|
|
662
663
|
const pullRequest = await github.createPullRequest(githubIssueMemory.repo_url, {
|
|
663
664
|
title: detail.title,
|
|
664
665
|
body: buildInitialPullRequestBody(detail.number, detail.body),
|
|
665
666
|
head: nextBranchName,
|
|
666
|
-
base:
|
|
667
|
+
base: defaultBranch,
|
|
667
668
|
draft: true
|
|
668
669
|
});
|
|
669
670
|
githubIssueMemory.pr_url = pullRequest.url;
|
package/src/github.js
CHANGED
|
@@ -257,6 +257,17 @@ export function createGitHubClient(config) {
|
|
|
257
257
|
};
|
|
258
258
|
},
|
|
259
259
|
|
|
260
|
+
async getDefaultBranch(repoUrl) {
|
|
261
|
+
const repo = parseGitHubRepoUrl(repoUrl);
|
|
262
|
+
const payload = await requestGitHub(
|
|
263
|
+
`https://api.github.com/repos/${repo.owner}/${repo.name}`,
|
|
264
|
+
config,
|
|
265
|
+
{ method: "GET" },
|
|
266
|
+
repo
|
|
267
|
+
);
|
|
268
|
+
return payload.default_branch;
|
|
269
|
+
},
|
|
270
|
+
|
|
260
271
|
async createPullRequest(repoUrl, pullRequest) {
|
|
261
272
|
const repo = parseGitHubRepoUrl(repoUrl);
|
|
262
273
|
const payload = await requestGitHub(
|
package/src/repo.js
CHANGED
|
@@ -54,18 +54,18 @@ export async function validateOrEnsureLocalRepo(repoUrl, reposDir, localPath = "
|
|
|
54
54
|
return ensureLocalRepo(repoUrl, reposDir);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export async function
|
|
57
|
+
export async function ensureBranchFromDefault(repoPath, branchName, baseBranch) {
|
|
58
58
|
try {
|
|
59
|
-
await execGit(repoPath, ["fetch", "origin",
|
|
59
|
+
await execGit(repoPath, ["fetch", "origin", baseBranch, "--prune"]);
|
|
60
60
|
} catch (error) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!isMissingRemoteBranchError(error)) {
|
|
62
62
|
throw error;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
await
|
|
65
|
+
await initializeRemoteDefaultBranch(repoPath, baseBranch);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
await execGit(repoPath, ["checkout", "-B", branchName,
|
|
68
|
+
await execGit(repoPath, ["checkout", "-B", branchName, `origin/${baseBranch}`]);
|
|
69
69
|
await execGit(repoPath, [
|
|
70
70
|
"-c",
|
|
71
71
|
"user.name=Claude Teammate",
|
|
@@ -79,6 +79,10 @@ export async function ensureBranchFromMain(repoPath, branchName) {
|
|
|
79
79
|
await execGit(repoPath, ["push", "-u", "origin", branchName]);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export async function ensureBranchFromMain(repoPath, branchName) {
|
|
83
|
+
return ensureBranchFromDefault(repoPath, branchName, "main");
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
export async function prepareRepoForBranch(repoPath, branchName) {
|
|
83
87
|
await execGit(repoPath, ["fetch", "origin", branchName, "--prune"]);
|
|
84
88
|
await execGit(repoPath, ["reset", "--hard"]);
|
|
@@ -211,8 +215,8 @@ async function branchHasChangesAgainstMain(repoPath) {
|
|
|
211
215
|
return Number.isFinite(count) && count > 0;
|
|
212
216
|
}
|
|
213
217
|
|
|
214
|
-
async function
|
|
215
|
-
await execGit(repoPath, ["checkout", "--orphan",
|
|
218
|
+
async function initializeRemoteDefaultBranch(repoPath, baseBranch) {
|
|
219
|
+
await execGit(repoPath, ["checkout", "--orphan", baseBranch]);
|
|
216
220
|
await execGit(repoPath, [
|
|
217
221
|
"-c",
|
|
218
222
|
"user.name=Claude Teammate",
|
|
@@ -221,9 +225,9 @@ async function initializeRemoteMainBranch(repoPath) {
|
|
|
221
225
|
"commit",
|
|
222
226
|
"--allow-empty",
|
|
223
227
|
"-m",
|
|
224
|
-
|
|
228
|
+
`Initialize ${baseBranch}`
|
|
225
229
|
]);
|
|
226
|
-
await execGit(repoPath, ["push", "-u", "origin",
|
|
230
|
+
await execGit(repoPath, ["push", "-u", "origin", baseBranch]);
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
function formatGitExecError(error) {
|
|
@@ -241,9 +245,9 @@ function formatGitExecError(error) {
|
|
|
241
245
|
return new Error(`${message}\n${detail}`);
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
function
|
|
248
|
+
function isMissingRemoteBranchError(error) {
|
|
245
249
|
const message = error instanceof Error ? error.message : String(error);
|
|
246
|
-
return /couldn't find remote ref
|
|
250
|
+
return /couldn't find remote ref /u.test(message);
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
function parseGitHubPath(rawPath) {
|