-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c72a5a5
commit 594b9b0
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const env = process.env | ||
const _ = require("lodash") | ||
const exec = require("child_process").execSync | ||
|
||
function getNumberOfCommitsOnBranch() { | ||
const grepAgument = `refs/heads/${env.CIRCLE_BRANCH}` | ||
const notArgument = `$(git for-each-ref --format="%(refname)" refs/heads/ | grep -v ${grepAgument})` | ||
return _.toNumber( | ||
exec( | ||
`git log ${env.CIRCLE_BRANCH} --oneline --not ${notArgument} | wc -l` | ||
).toString() | ||
) | ||
} | ||
|
||
function getCommitMessage() { | ||
return exec('git log --format="%s" -n1 $CIRCLE_SHA1').toString() | ||
} | ||
|
||
module.exports = { | ||
// The GitHub repo slug | ||
repoSlug: `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}`, | ||
// The name of the current branch | ||
branchName: env.CIRCLE_BRANCH, | ||
// The commit message of the last commit on the current branch | ||
commitMessage: getCommitMessage(), | ||
// Is this the first push on this branch | ||
// i.e. the Greenkeeper commit | ||
firstPush: getNumberOfCommitsOnBranch() === 1, | ||
// Is this a regular build | ||
correctBuild: _.isEmpty(env.CI_PULL_REQUEST), | ||
// Should the lockfile be uploaded from this build | ||
uploadBuild: env.CIRCLE_NODE_INDEX === "0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const env = process.env | ||
|
||
module.exports = { | ||
travis: () => env.TRAVIS === 'true' | ||
travis: () => env.TRAVIS === 'true', | ||
circleci: () => env.CIRCLECI === 'true' | ||
} |