Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: checkout merge base for cherry diff #37

Merged
merged 15 commits into from
Jan 22, 2024
2 changes: 1 addition & 1 deletion .github/workflows/cherry_diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
run: npm install

- name: Raise if new JavaScript code is added
run: ./bin/cherry.js diff --metric='[loc] JavaScript' --api-key=${{ secrets.CHERRY_API_KEY }} --error-if-increase --quiet
run: ./bin/cherry.js diff --metric='[loc] JavaScript' --error-if-increase --quiet
6 changes: 2 additions & 4 deletions src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ export const getDefaultBranchName = async () => {
return defaultBranch.replace('origin/', '').trim()
}

export const getMergeBase = async (currentBranchName, defaultBranchName) => {
const mergeBase = (await git(`merge-base ${currentBranchName} ${defaultBranchName}`)).toString()
return mergeBase.trim()
}
export const getMergeBase = async (currentBranchName, defaultBranchName) =>
(await git(`merge-base ${currentBranchName} origin/${defaultBranchName}`)).toString().trim()

export const authorName = async (sha) => (await git(`show ${sha} --format=%an --no-patch`))[0]

Expand Down