All files / infrastructure/scripts/src/issue/adapters git.ts

71.42% Statements 5/7
100% Branches 0/0
50% Functions 2/4
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14      1x 3x   8x   1x       1x  
import { git } from "../../shared/adapters/git.ts";
 
/** Reuse an existing issue branch so checkout does not fail on a duplicate ref. */
export const branchForIssue = (issue: number): string | undefined =>
    git("branch", "--format=%(refname:short)")
        .split("\n")
        .find((name) => new RegExp(`^[^/]+/[^/]+/${issue}-`).test(name));
 
export const checkout = (branch: string): void => {
    git("checkout", branch);
};
 
export const currentBranch = (): string => git("rev-parse", "--abbrev-ref", "HEAD");