Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions pstack/skills/poteto-mode/scripts/orch/orch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,27 @@ describe("Store", () => {
}
});

it(`resolves ${forge} branches when tags share their names`, async () => {
const { directory, store } = await initializedStore();
const stack = await makeGitStack(directory);
git({ repo: stack.repo, args: ["tag", "stack/open", "main"] });
git({ repo: stack.repo, args: ["tag", "stack/closed", "main"] });
await withFakeForge({
directory, forge,
operation: async () => {
const frontier = await store.frontier.set({ repo: stack.repo, forge });
expect(
frontier.prs.map((row) => [row.branches, row.sha])
).toEqual([
["stack/merged", stack.mergedSha],
["stack/closed", stack.closedSha],
["stack/open", stack.openSha],
["stack/draft", stack.draftSha],
]);
},
});
});

it(`still rejects multiple active ${forge} PRs on one branch`, async () => {
const { directory, store } = await initializedStore();
const stack = await makeGitStack(directory);
Expand Down
11 changes: 9 additions & 2 deletions pstack/skills/poteto-mode/scripts/orch/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,15 +1162,22 @@ function branchSha({
branch: string;
repo: string;
}): string {
const sha = runGit({ args: ["rev-parse", branch], repo });
const sha = runGit({
args: ["rev-parse", "--verify", `refs/heads/${branch}^{commit}`],
repo,
});
if (!/^[0-9a-f]{40,64}$/i.test(sha)) {
throw new UserError(`git rev-parse ${branch} returned an invalid SHA`);
}
return sha;
}

function currentBranch(repo: string): string {
return runGit({ args: ["symbolic-ref", "--short", "HEAD"], repo });
// --short abbreviates to heads/<branch> when a tag shares the branch name.
return runGit({ args: ["symbolic-ref", "HEAD"], repo }).replace(
/^refs\/heads\//,
""
);
}

function trunkBranch(repo: string): string {
Expand Down
Loading