@@ -313,6 +313,15 @@ func isChild(parentPath, childPath string) bool {
313
313
return ! strings .HasPrefix (relPath , ".." )
314
314
}
315
315
316
+ func recursiveFiles (path string ) (paths []string , err error ) {
317
+ paths = []string {strings .ToLower (path )}
318
+ err = filepath .Walk (path , func (path string , info os.FileInfo , err error ) error {
319
+ paths = append (paths , strings .ToLower (path ))
320
+ return nil
321
+ })
322
+ return
323
+ }
324
+
316
325
// This function retrieves the important file information
317
326
// for every file that will be transferred
318
327
func GetFilesInfo (fnames []string , zipfolder bool , ignoreGit bool , exclusions []string ) (filesInfo []FileInfo , emptyFolders []FileInfo , totalNumberFolders int , err error ) {
@@ -380,18 +389,6 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
380
389
}
381
390
382
391
absPath , errAbs := filepath .Abs (fpath )
383
- absPathLower := strings .ToLower (absPath )
384
- ignorePath := false
385
- for _ , exclusion := range exclusions {
386
- if strings .Contains (absPathLower , exclusion ) {
387
- ignorePath = true
388
- break
389
- }
390
- }
391
- if ignorePath {
392
- log .Debugf ("Ignoring %s" , absPath )
393
- continue
394
- }
395
392
396
393
if errAbs != nil {
397
394
err = errAbs
@@ -426,6 +423,21 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
426
423
TempFile : true ,
427
424
IsIgnored : ignoredPaths [absPath ],
428
425
}
426
+ // check if exclusions apply to this file
427
+ if len (exclusions ) > 0 && ! fInfo .IsIgnored {
428
+ allFiles , _ := recursiveFiles (absPath )
429
+ for _ , exclusion := range exclusions {
430
+ for _ , file := range allFiles {
431
+ if strings .Contains (strings .ToLower (file ), strings .ToLower (exclusion )) {
432
+ fInfo .IsIgnored = true
433
+ break
434
+ }
435
+ }
436
+ if fInfo .IsIgnored {
437
+ break
438
+ }
439
+ }
440
+ }
429
441
if fInfo .IsIgnored {
430
442
continue
431
443
}
@@ -458,7 +470,23 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
458
470
TempFile : false ,
459
471
IsIgnored : ignoredPaths [pathName ],
460
472
}
461
- if fInfo .IsIgnored && ignoreGit {
473
+ // check if exclusions apply to this file
474
+ if len (exclusions ) > 0 && ! fInfo .IsIgnored {
475
+ allFiles , _ := recursiveFiles (pathName )
476
+ for _ , exclusion := range exclusions {
477
+ for _ , file := range allFiles {
478
+ log .Tracef ("ignoring test: %s %s %v" , strings .ToLower (file ), strings .ToLower (exclusion ), strings .Contains (strings .ToLower (file ), strings .ToLower (exclusion )))
479
+ if strings .Contains (strings .ToLower (file ), strings .ToLower (exclusion )) {
480
+ fInfo .IsIgnored = true
481
+ break
482
+ }
483
+ }
484
+ if fInfo .IsIgnored {
485
+ break
486
+ }
487
+ }
488
+ }
489
+ if fInfo .IsIgnored && (ignoreGit || len (exclusions ) > 0 ) {
462
490
return nil
463
491
} else {
464
492
filesInfo = append (filesInfo , fInfo )
@@ -494,7 +522,22 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
494
522
TempFile : false ,
495
523
IsIgnored : ignoredPaths [absPath ],
496
524
}
497
- if fInfo .IsIgnored && ignoreGit {
525
+ if len (exclusions ) > 0 && ! fInfo .IsIgnored {
526
+ allFiles , _ := recursiveFiles (absPath )
527
+ for _ , exclusion := range exclusions {
528
+ for _ , file := range allFiles {
529
+ log .Tracef ("ignoring test: %s %s %v" , strings .ToLower (file ), strings .ToLower (exclusion ), strings .Contains (strings .ToLower (file ), strings .ToLower (exclusion )))
530
+ if strings .Contains (strings .ToLower (file ), strings .ToLower (exclusion )) {
531
+ fInfo .IsIgnored = true
532
+ break
533
+ }
534
+ }
535
+ if fInfo .IsIgnored {
536
+ break
537
+ }
538
+ }
539
+ }
540
+ if fInfo .IsIgnored && (ignoreGit || len (exclusions ) > 0 ) {
498
541
continue
499
542
} else {
500
543
filesInfo = append (filesInfo , fInfo )
0 commit comments