Skip to content

Commit

Permalink
fix: checkout merge base for cherry diff (#37)
Browse files Browse the repository at this point in the history
* chore: cosmetic

* chore: remove api key

* chore: list branches

* chore: echo head ref

* chore: show ref

* chore: rev parse head

* chore: head ref

* chore: origin/main

* chore: origin/main

* chore: fetch main

* chore: fetch main

* chore: checkout main

* chore: checkout main via cli

* chore: merge base with origin

* feat: checkout merge base for cherry diff
  • Loading branch information
fwuensche authored Jan 22, 2024
1 parent 5c3916e commit db1106b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
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

0 comments on commit db1106b

Please sign in to comment.