-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commit): allow override options passed to git commit
- Loading branch information
Showing
2 changed files
with
54 additions
and
4 deletions.
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
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 |
---|---|---|
|
@@ -133,6 +133,56 @@ describe('commit', function() { | |
}); | ||
|
||
}); | ||
|
||
it('should allow to override options passed to gulp-git', function(done) { | ||
|
||
this.timeout(config.maxTimeout); // this could take a while | ||
|
||
// SETUP | ||
|
||
let dummyCommitMessage = `sip sip sippin on some sizzurp`; | ||
let author = `A U Thor <[email protected]>`; | ||
|
||
// Describe a repo and some files to add and commit | ||
let repoConfig = { | ||
path: config.paths.endUserRepo, | ||
files: { | ||
dummyfile: { | ||
contents: `duck-duck-goose`, | ||
filename: `mydummyfile.txt`, | ||
}, | ||
gitignore: { | ||
contents: `node_modules/`, | ||
filename: `.gitignore` | ||
} | ||
} | ||
}; | ||
|
||
// Describe an adapter | ||
let adapterConfig = { | ||
path: path.join(repoConfig.path, '/node_modules/cz-jira-smart-commit'), | ||
npmName: 'cz-jira-smart-commit' | ||
}; | ||
|
||
let options = { | ||
args: `--author="${author}" --no-edit` | ||
}; | ||
|
||
// Quick setup the repos, adapter, and grab a simple prompter | ||
let prompter = quickPrompterSetup(sh, repoConfig, adapterConfig, dummyCommitMessage, options); | ||
// TEST | ||
|
||
// Pass in inquirer but it never gets used since we've mocked out a different | ||
// version of prompter. | ||
commitizenCommit(sh, inquirer, repoConfig.path, prompter, {disableAppendPaths:true, quiet:true, emitData:true}, function() { | ||
log(repoConfig.path, function(logOutput) { | ||
expect(logOutput).to.have.string(author); | ||
expect(logOutput).to.have.string(dummyCommitMessage); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
|
@@ -151,7 +201,7 @@ after(function() { | |
* This is just a helper for testing. NOTE that prompter | ||
* prompter is overriden for testing purposes. | ||
*/ | ||
function quickPrompterSetup(sh, repoConfig, adapterConfig, commitMessage) { | ||
function quickPrompterSetup(sh, repoConfig, adapterConfig, commitMessage, options={}) { | ||
|
||
commitizenInit(sh, repoConfig.path, adapterConfig.npmName); | ||
|
||
|
@@ -160,7 +210,7 @@ function quickPrompterSetup(sh, repoConfig, adapterConfig, commitMessage) { | |
// we'll provide prompter. We'd normally use: | ||
// let prompter = getPrompter(adapterConfig.path); | ||
let prompter = function(cz, commit) { | ||
commit(commitMessage); | ||
commit(commitMessage, options); | ||
} | ||
|
||
gitInit(sh, repoConfig.path); | ||
|