Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3d8594d49 | ||
|
|
1d107bd84a |
No files matched your search
@@ -1298,7 +1298,19 @@ export const make = Effect.gen(function* () {
|
||||
phase: "pr",
|
||||
label: `Generating ${terms.shortLabel} content...`,
|
||||
});
|
||||
const rangeContext = yield* gitCore.readRangeContext(cwd, baseBranch);
|
||||
const rangeBaseRef = yield* gitCore.resolvePrimaryRemoteName(cwd).pipe(
|
||||
Effect.map((remote) =>
|
||||
baseBranch.startsWith(`${remote}/`) ? baseBranch : `${remote}/${baseBranch}`,
|
||||
),
|
||||
Effect.orElseSucceed(() => baseBranch),
|
||||
);
|
||||
const rangeContext = yield* (
|
||||
rangeBaseRef === baseBranch
|
||||
? gitCore.readRangeContext(cwd, rangeBaseRef)
|
||||
: gitCore.readRangeContext(cwd, rangeBaseRef).pipe(
|
||||
Effect.catch(() => gitCore.readRangeContext(cwd, baseBranch)),
|
||||
)
|
||||
);
|
||||
|
||||
const generated = yield* textGeneration.generatePrContent({
|
||||
cwd,
|
||||
|
||||
@@ -6041,6 +6041,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
||||
cwd: "/tmp/project",
|
||||
refName: fetchedOriginCommit,
|
||||
newRefName: "t3code/bootstrap-refName",
|
||||
baseRefName: "main",
|
||||
path: null,
|
||||
});
|
||||
assert.deepEqual(fetchRemote.mock.calls[0]?.[0], {
|
||||
|
||||
@@ -568,13 +568,21 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
|
||||
path: worktreePath,
|
||||
refName: resolvedBase.commitSha,
|
||||
newRefName: "t3code/fetched-origin",
|
||||
baseRefName: resolvedBase.remoteRefName,
|
||||
});
|
||||
|
||||
assert.equal(yield* git(worktreePath, ["rev-parse", "HEAD"]), remoteHead);
|
||||
assert.equal(
|
||||
yield* driver.readConfigValue(worktreePath, "branch.t3code/fetched-origin.gh-merge-base"),
|
||||
initialBranch,
|
||||
);
|
||||
assert.equal(
|
||||
yield* driver.readConfigValue(worktreePath, "branch.t3code/fetched-origin.remote"),
|
||||
null,
|
||||
);
|
||||
const status = yield* driver.statusDetails(worktreePath);
|
||||
assert.equal(status.aheadCount, 0);
|
||||
assert.equal(status.aheadOfDefaultCount, 0);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -1130,16 +1130,16 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
continue;
|
||||
}
|
||||
|
||||
if (yield* branchExists(cwd, normalizedCandidate)) {
|
||||
return normalizedCandidate;
|
||||
}
|
||||
|
||||
if (
|
||||
primaryRemoteName &&
|
||||
(yield* remoteBranchExists(cwd, primaryRemoteName, normalizedCandidate))
|
||||
) {
|
||||
return `${primaryRemoteName}/${normalizedCandidate}`;
|
||||
}
|
||||
|
||||
if (yield* branchExists(cwd, normalizedCandidate)) {
|
||||
return normalizedCandidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -2178,6 +2178,20 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
|
||||
fallbackErrorMessage: "git worktree add failed",
|
||||
});
|
||||
|
||||
if (input.newRefName && input.baseRefName) {
|
||||
const remoteNames = yield* listRemoteNames(input.cwd).pipe(Effect.orElseSucceed(() => []));
|
||||
const parsedBaseRef = parseRemoteRefWithRemoteNames(
|
||||
input.baseRefName,
|
||||
remoteNames.toSorted((left, right) => right.length - left.length),
|
||||
);
|
||||
const baseBranch = parsedBaseRef?.branchName ?? input.baseRefName;
|
||||
yield* runGit("GitVcsDriver.createWorktree.configureBaseRef", input.cwd, [
|
||||
"config",
|
||||
`branch.${input.newRefName}.gh-merge-base`,
|
||||
baseBranch,
|
||||
]);
|
||||
}
|
||||
|
||||
return {
|
||||
worktree: {
|
||||
path: worktreePath,
|
||||
|
||||
@@ -712,6 +712,7 @@ const makeWsRpcLayer = (currentSession: EnvironmentAuth.AuthenticatedSession) =>
|
||||
cwd: bootstrap.prepareWorktree.projectCwd,
|
||||
refName: worktreeBaseRef,
|
||||
newRefName: bootstrap.prepareWorktree.branch,
|
||||
baseRefName: bootstrap.prepareWorktree.baseBranch,
|
||||
path: null,
|
||||
});
|
||||
targetWorktreePath = worktree.worktree.path;
|
||||
|
||||
@@ -28,6 +28,18 @@ describe("VcsCreateWorktreeInput", () => {
|
||||
expect(parsed.newRefName).toBeUndefined();
|
||||
expect(parsed.refName).toBe("feature/existing");
|
||||
});
|
||||
|
||||
it("accepts baseRefName metadata for a new worktree ref", () => {
|
||||
const parsed = decodeCreateWorktreeInput({
|
||||
cwd: "/repo",
|
||||
refName: "0123456789abcdef",
|
||||
newRefName: "feature/new",
|
||||
baseRefName: "origin/main",
|
||||
path: "/tmp/worktree",
|
||||
});
|
||||
|
||||
expect(parsed.baseRefName).toBe("origin/main");
|
||||
});
|
||||
});
|
||||
|
||||
describe("GitPreparePullRequestThreadInput", () => {
|
||||
|
||||
@@ -137,6 +137,7 @@ export const VcsCreateWorktreeInput = Schema.Struct({
|
||||
cwd: TrimmedNonEmptyStringSchema,
|
||||
refName: TrimmedNonEmptyStringSchema,
|
||||
newRefName: Schema.optional(TrimmedNonEmptyStringSchema),
|
||||
baseRefName: Schema.optional(TrimmedNonEmptyStringSchema),
|
||||
path: Schema.NullOr(TrimmedNonEmptyStringSchema),
|
||||
});
|
||||
export type VcsCreateWorktreeInput = typeof VcsCreateWorktreeInput.Type;
|
||||
|
||||
Reference in new issue
Block a user