Skip to content

Commit

Permalink
fix autodetect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zlalvani committed May 13, 2024
1 parent 5a53adc commit 68328c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/bumpgen-core/src/services/git/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ export const createGitService = (
raw: git,
getMainBranch: async (cwd: string) => {
await git.cwd(cwd);
return (
const mainBranch = (
await subprocess.exec(
"git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'",
{
cwd,
},
)
).trim();

if (!mainBranch) {
return null;
}

return mainBranch;
},
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const makeTypescriptService = (
// if there are no changes in the package.json, we check against the main branch
if (!diff) {
const mainBranch = await git.getMainBranch(projectRoot);
diff = await git.raw.diff([mainBranch, "package.json"]);
diff = mainBranch ?? "";
}

const upgradedPackages = [];
Expand Down

0 comments on commit 68328c0

Please sign in to comment.