mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-06 15:20:25 -06:00
@@ -407,14 +407,22 @@ const commitDefaults = function (existingInfo) {
|
||||
debug('git commit existing info')
|
||||
debug(existingInfo)
|
||||
|
||||
const commitParamsObj = commitParams() || {}
|
||||
const providerName = provider()
|
||||
debug('detected provider name: %s', providerName)
|
||||
|
||||
let commitParamsObj = commitParams()
|
||||
if (!commitParamsObj) {
|
||||
debug('could not get commit param object, using empty one')
|
||||
commitParamsObj = {}
|
||||
}
|
||||
|
||||
debug('commit info from provider environment variables')
|
||||
debug(commitParamsObj)
|
||||
debug('%o', commitParamsObj)
|
||||
|
||||
//# based on the existingInfo properties
|
||||
//# merge in the commitParams if null or undefined
|
||||
//# defaulting back to null if all fails
|
||||
// based on the existingInfo properties
|
||||
// merge in the commitParams if null or undefined
|
||||
// defaulting back to null if all fails
|
||||
// NOTE: only properties defined in "existingInfo" will be returned
|
||||
const combined = _.transform(existingInfo, (memo, value, key) => {
|
||||
return memo[key] = _.defaultTo(value != null ? value : commitParamsObj[key], null)
|
||||
})
|
||||
|
||||
@@ -14,6 +14,7 @@ expectsCommitParams = (params) ->
|
||||
expect(ciProvider.commitParams(), "CI providers detected commit params").to.deep.eq(params)
|
||||
|
||||
expectsCommitDefaults = (existing, expected) ->
|
||||
expect(expected).to.be.an("object")
|
||||
expect(ciProvider.commitDefaults(existing), "CI providers default git params").to.deep.eq(expected)
|
||||
|
||||
describe "lib/util/ci_provider", ->
|
||||
@@ -198,6 +199,15 @@ describe "lib/util/ci_provider", ->
|
||||
defaultBranch: "buildkitePipelineDefaultBranch"
|
||||
})
|
||||
|
||||
# in this test only interested in branch and sha for example
|
||||
expectsCommitDefaults({
|
||||
sha: null,
|
||||
branch: null
|
||||
}, {
|
||||
sha: "buildKiteCommit",
|
||||
branch: "buildKiteBranch"
|
||||
})
|
||||
|
||||
it "circle", ->
|
||||
resetEnv = mockedEnv({
|
||||
CIRCLECI: "true"
|
||||
|
||||
Reference in New Issue
Block a user