Skip to content

Commit

Permalink
fix: use current branch calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
lshadler committed Oct 21, 2021
1 parent d4ade35 commit 4cffcdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/core/src/auto.ts
Expand Up @@ -1685,9 +1685,7 @@ export default class Auto {
options: IShipItOptions
): Promise<ShipitInfo | undefined> {
const latestTag = await this.git?.getLatestTagInBranch(
env.branch ||
getCurrentBranch() ||
""
getCurrentBranch() || ""
);
const result = await this.publishFullRelease({
...options,
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/utils/get-current-branch.ts
Expand Up @@ -3,16 +3,21 @@ import { execSync } from "child_process";

const env = envCi();

/**
*
*/
const isValidBranch = (branch: string | undefined) => typeof branch === "string" && branch !== "undefined"

/** Get the current branch the git repo is set to */
export function getCurrentBranch() {
const isPR = "isPr" in env && env.isPr;
let branch: string | undefined;
// env-ci sets branch to target branch (ex: main) in some CI services.
// so we should make sure we aren't in a PR just to be safe

if (isPR && "prBranch" in env) {
if (isPR && "prBranch" in env && isValidBranch(env.prBranch)) {
branch = env.prBranch;
} else {
} else if(isValidBranch(env.branch)) {
branch = env.branch;
}

Expand Down

0 comments on commit 4cffcdd

Please sign in to comment.