@@ -12,7 +12,7 @@ import inquirer from 'inquirer';
1212import { bootstrap } from '../tester' ;
1313
1414// Get our source files
15- import { addPath as gitAdd , commit as gitCommit , init as gitInit , log } from '../../src/git' ;
15+ import { addPath as gitAdd , addFile as gitAddFile , commit as gitCommit , init as gitInit , log , whatChanged } from '../../src/git' ;
1616import { commit as commitizenCommit , init as commitizenInit , adapter } from '../../src/commitizen' ;
1717
1818// Destructure some things for cleaner tests
@@ -232,6 +232,63 @@ describe('commit', function () {
232232
233233 } ) ;
234234
235+ it ( 'should respect original behavior of -a option' , function ( done ) {
236+
237+ this . timeout ( config . maxTimeout ) ; // this could take a while
238+
239+ // SETUP
240+
241+ let dummyCommitMessage = `sip sip sippin on some sizzurp` ;
242+
243+ // Describe a repo and some files to add and commit
244+ let repoConfig = {
245+ path : config . paths . endUserRepo ,
246+ files : {
247+ dummyfile : {
248+ contents : `duck-duck-goose` ,
249+ filename : `mydummyfile.txt` ,
250+ } ,
251+ dummyfilecopy : {
252+ contents : `duck-duck-goose` ,
253+ filename : `mydummyfilecopy.txt` ,
254+ add : false ,
255+ } ,
256+ gitignore : {
257+ contents : `node_modules/` ,
258+ filename : `.gitignore`
259+ }
260+ }
261+ } ;
262+
263+ // Describe an adapter
264+ let adapterConfig = {
265+ path : path . join ( repoConfig . path , '/node_modules/cz-jira-smart-commit' ) ,
266+ npmName : 'cz-jira-smart-commit'
267+ } ;
268+
269+ let options = {
270+ args : [ '-a' ]
271+ } ;
272+
273+ // Quick setup the repos, adapter, and grab a simple prompter
274+ let prompter = quickPrompterSetup ( sh , repoConfig , adapterConfig , dummyCommitMessage , options ) ;
275+ // TEST
276+
277+ // Pass in inquirer but it never gets used since we've mocked out a different
278+ // version of prompter.
279+ commitizenCommit ( sh , inquirer , repoConfig . path , prompter , { disableAppendPaths : true , quiet : true , emitData : true } , function ( ) {
280+ log ( repoConfig . path , function ( logOutput ) {
281+ expect ( logOutput ) . to . have . string ( dummyCommitMessage ) ;
282+ } ) ;
283+ whatChanged ( repoConfig . path , function ( whatChangedOutput ) {
284+ expect ( whatChangedOutput ) . to . have . string ( 'A\t' + repoConfig . files . dummyfile . filename ) ;
285+ expect ( whatChangedOutput ) . to . not . have . string ( 'A\t' + repoConfig . files . dummyfilecopy . filename ) ;
286+ done ( ) ;
287+ } ) ;
288+ } ) ;
289+
290+ } ) ;
291+
235292} ) ;
236293
237294afterEach ( function ( ) {
@@ -267,7 +324,12 @@ function quickPrompterSetup (sh, repoConfig, adapterConfig, commitMessage, optio
267324
268325 writeFilesToPath ( repoConfig . files , repoConfig . path ) ;
269326
270- gitAdd ( sh , repoConfig . path ) ;
327+ for ( let key in repoConfig . files ) {
328+ let file = repoConfig . files [ key ] ;
329+ if ( file . add !== false ) {
330+ gitAddFile ( sh , repoConfig . path , file . filename ) ;
331+ }
332+ }
271333
272334 // NOTE: In the real world we would not be returning
273335 // this we would instead be just making the commented
0 commit comments