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

Broken gitHelpers.getNumberOfCommitsOnBranch on CircleCI #144

Open
patkub opened this issue Apr 20, 2018 · 1 comment
Open

Broken gitHelpers.getNumberOfCommitsOnBranch on CircleCI #144

patkub opened this issue Apr 20, 2018 · 1 comment

Comments

@patkub
Copy link
Contributor

patkub commented Apr 20, 2018

gitHelpers.getNumberOfCommitsOnBranch does not work on CircleCI.

The refactoring of gitHelpers.getNumberOfCommitsOnBranch in #35 changed its output on CircleCI.
Test: https://github.com/patkub/test-gk-lock-git-helpers/blob/master/index.js

On a greenkeeper branch, both methods fail and return 0.
CircleCI build: https://circleci.com/gh/patkub/test-gk-lock-git-helpers/35

Number of commits on branch: 0
Number of commits on branch (old method): 0

But, on the master branch, the old method properly detects the number of commits, while the new method returns 0.
CircleCI build: https://circleci.com/gh/patkub/test-gk-lock-git-helpers/33

Number of commits on branch: 0
Number of commits on branch (old method): 15

The old method prior to #35 was

getNumberOfCommitsOnBranch: function getNumberOfCommitsOnBranch (branch) {
const grepAgument = `refs/heads/${branch}`
const notArgument = `$(git for-each-ref --format="%(refname)" refs/heads/ | grep -v ${grepAgument})`
return _.toNumber(
exec(
`git log ${branch} --oneline --not ${notArgument} | wc -l`
).toString()
)
}

Current method is:

getNumberOfCommitsOnBranch: function getNumberOfCommitsOnBranch (branch) {
const refArgument = `$(git for-each-ref '--format=%(refname)' refs/ | grep /${branch} | head -1)`
const notArgument = `$(git for-each-ref '--format=%(refname)' refs/ | grep -v /${branch})`
return _.toNumber(
exec(
`git log ${refArgument} --oneline --not ${notArgument} | wc -l`
).toString()
)
},

@patkub
Copy link
Contributor Author

patkub commented Apr 20, 2018

@nevir Any thoughts on how to fix this for CircleCI and not potentially break other CIs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant