Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions apps/server/src/git/GitManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
return { repoDir, manager, providerCalls, firstCommit, pullHead };
});

it.effect.each(["switch", "create-and-switch", "feature-branch"] as const)(
it.effect.each(["switch", "create-and-switch", "feature-branch", "commit"] as const)(
"local PR checkout excludes a concurrent %s from a nested project with an alternate root",
(operation) =>
Effect.gen(function* () {
Expand Down Expand Up @@ -3846,7 +3846,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
...manager,
runStackedAction: (input, options) =>
Effect.sync(() => {
events.push("feature-branch");
events.push(input.featureBranch ? "feature-branch" : "commit");
NodeFS.writeFileSync(
NodePath.join(repoDir, "second-client.txt"),
"second client\n",
Expand Down Expand Up @@ -3883,9 +3883,9 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
})
: workflows[1]!.runStackedAction({
cwd: nestedCwd,
actionId: "second-client-feature-branch",
actionId: `second-client-${operation}`,
action: "commit",
featureBranch: true,
featureBranch: operation === "feature-branch",
commitMessage: "Second client commit",
}),
{ startImmediately: true },
Expand All @@ -3898,15 +3898,17 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
expect(events).toEqual([operation]);
expect(prepared).toMatchObject({ branch: "feature/pr-safe", isOnPullRequestHead: true });
expect((yield* runGit(repoDir, ["rev-parse", "main"])).stdout.trim()).toBe(mainCommit);
expect((yield* runGit(repoDir, ["rev-parse", "feature/pr-safe"])).stdout.trim()).toBe(
pullHead,
);
// An ordinary commit lands on the checked-out PR branch once the checkout finishes.
const pullBranch = operation === "commit" ? "feature/pr-safe^" : "feature/pr-safe";
expect((yield* runGit(repoDir, ["rev-parse", pullBranch])).stdout.trim()).toBe(pullHead);
expect((yield* runGit(repoDir, ["branch", "--show-current"])).stdout.trim()).toBe(
operation === "switch"
? "main"
: "branch" in switched
? switched.branch.name
: "second-client",
: operation === "commit"
? "feature/pr-safe"
: "branch" in switched
? switched.branch.name
: "second-client",
);
if ("commit" in switched) {
expect(switched.commit.status).toBe("created");
Expand Down
11 changes: 5 additions & 6 deletions apps/server/src/git/GitWorkflowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,14 @@ export const make = Effect.gen(function* () {
ensureGitCommand("GitWorkflowService.pullCurrentBranch", cwd).pipe(
Effect.andThen(git.pullCurrentBranch(cwd)),
),
// A switch between reading the branch and committing would move the commit to another branch.
runStackedAction: (input, options) =>
ensureGit("GitWorkflowService.runStackedAction", input.cwd).pipe(
Effect.flatMap((handle) =>
input.featureBranch
? withCheckoutLease(
handle.repository.rootPath,
gitManager.runStackedAction(input, options),
)
: gitManager.runStackedAction(input, options),
withCheckoutLease(
handle.repository.rootPath,
gitManager.runStackedAction(input, options),
),
),
),
resolvePullRequest: routeGitManager(
Expand Down
Loading