function shouldUseExistingPRBranch()

in src/github/operations/branch.ts [40:81]


function shouldUseExistingPRBranch(
    silentMode: boolean,
    createNewBranchForPR: boolean,
    actor: string,
    prAuthor: string,
    tokenOwnerLogin: string,
    state: string
): boolean {
    console.log(`Silent mode: ${silentMode}`);
    console.log(`PR author: ${prAuthor}`);
    console.log(`Actor: ${actor}`);
    console.log(`Token owner: ${tokenOwnerLogin}`);
    console.log(`Create new branch setting: ${createNewBranchForPR}`);

    if (state === "CLOSED" || state === "MERGED") {
        console.log(`Create new branch: PR is ${state}`);
        return true;
    }

    if (createNewBranchForPR) {
        console.log(`Create new branch: createNewBranchForPR setting is enabled`);
        return false;
    }

    if (silentMode) {
        console.log(`Using existing branch: silent mode is enabled`);
        return true;
    }

    if (actor === prAuthor) {
        console.log(`Using existing branch: actor is PR author`);
        return true;
    }

    if (prAuthor === tokenOwnerLogin) {
        console.log(`Using existing branch: PR author is token owner`);
        return true;
    }

    console.log(`Creating new branch: none of the conditions matched`);
    return false;
}