@@ -12,7 +12,7 @@ import inquirer from 'inquirer';
12
12
import { bootstrap } from '../tester' ;
13
13
14
14
// 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' ;
16
16
import { commit as commitizenCommit , init as commitizenInit , adapter } from '../../src/commitizen' ;
17
17
18
18
// Destructure some things for cleaner tests
@@ -232,6 +232,63 @@ describe('commit', function () {
232
232
233
233
} ) ;
234
234
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
+
235
292
} ) ;
236
293
237
294
afterEach ( function ( ) {
@@ -267,7 +324,12 @@ function quickPrompterSetup (sh, repoConfig, adapterConfig, commitMessage, optio
267
324
268
325
writeFilesToPath ( repoConfig . files , repoConfig . path ) ;
269
326
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
+ }
271
333
272
334
// NOTE: In the real world we would not be returning
273
335
// this we would instead be just making the commented
0 commit comments