Skip to content

Commit e8758f6

Browse files
committed
fix
1 parent dfcd032 commit e8758f6

File tree

4 files changed

+49
-52
lines changed

4 files changed

+49
-52
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg"
55
width="408px" border="0" alt="croc">
66
<br>
7-
<a href="https://github.com/schollz/croc/releases/latest"><img src="https://img.shields.io/badge/version-v10.2.0-brightgreen.svg?style=flat-square" alt="Version"></a>
7+
<a href="https://github.com/schollz/croc/releases/latest"><img src="https://img.shields.io/badge/version-v10.2.1-brightgreen.svg?style=flat-square" alt="Version"></a>
88
<a href="https://github.com/schollz/croc/actions/workflows/ci.yml"><img
99
src="https://github.com/schollz/croc/actions/workflows/ci.yml/badge.svg" alt="Build
1010
Status"></a>

src/cli/cli.go

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func Run() (err error) {
3636
app := cli.NewApp()
3737
app.Name = "croc"
3838
if Version == "" {
39-
Version = "v10.2.0"
39+
Version = "v10.2.1"
4040
}
4141
app.Version = Version
4242
app.Compiled = time.Now()
@@ -431,6 +431,49 @@ Or you can go back to the classic croc behavior by enabling classic mode:
431431
if err != nil {
432432
return
433433
}
434+
minimalFileInfosInclude := []croc.FileInfo{}
435+
exclusions := []string{}
436+
for _, exclude := range crocOptions.Exclude {
437+
exclusions = append(exclusions, strings.ToLower(exclude))
438+
}
439+
for _, f := range minimalFileInfos {
440+
exclude := false
441+
for _, exclusion := range exclusions {
442+
if strings.Contains(path.Join(strings.ToLower(f.FolderRemote), strings.ToLower(f.Name)), exclusion) {
443+
exclude = true
444+
break
445+
}
446+
}
447+
if !exclude {
448+
minimalFileInfosInclude = append(minimalFileInfosInclude, f)
449+
}
450+
}
451+
emptyFoldersToTransferInclude := []croc.FileInfo{}
452+
for _, f := range emptyFoldersToTransfer {
453+
exclude := false
454+
for _, exclusion := range exclusions {
455+
if strings.Contains(path.Join(strings.ToLower(f.FolderRemote), strings.ToLower(f.Name)), exclusion) {
456+
exclude = true
457+
break
458+
}
459+
}
460+
if !exclude {
461+
emptyFoldersToTransferInclude = append(emptyFoldersToTransferInclude, f)
462+
}
463+
}
464+
465+
totalNumberFolders = 0
466+
folderMap := make(map[string]bool)
467+
for _, f := range minimalFileInfosInclude {
468+
folderMap[f.FolderRemote] = true
469+
log.Tracef("zxvc file: %+v", f)
470+
// is folder
471+
}
472+
for _, f := range emptyFoldersToTransferInclude {
473+
log.Tracef("zxvc folder: %+v", f)
474+
}
475+
totalNumberFolders = len(folderMap)
476+
log.Debugf("zxvc total number of folders: %d", totalNumberFolders)
434477

435478
cr, err := croc.New(crocOptions)
436479
if err != nil {
@@ -440,7 +483,7 @@ Or you can go back to the classic croc behavior by enabling classic mode:
440483
// save the config
441484
saveConfig(c, crocOptions)
442485

443-
err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders)
486+
err = cr.Send(minimalFileInfosInclude, emptyFoldersToTransferInclude, totalNumberFolders)
444487

445488
return
446489
}

src/croc/croc.go

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -423,21 +423,6 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
423423
TempFile: true,
424424
IsIgnored: ignoredPaths[absPath],
425425
}
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-
}
441426
if fInfo.IsIgnored {
442427
continue
443428
}
@@ -470,23 +455,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
470455
TempFile: false,
471456
IsIgnored: ignoredPaths[pathName],
472457
}
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) {
458+
if fInfo.IsIgnored && ignoreGit {
490459
return nil
491460
} else {
492461
filesInfo = append(filesInfo, fInfo)
@@ -522,22 +491,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
522491
TempFile: false,
523492
IsIgnored: ignoredPaths[absPath],
524493
}
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) {
494+
if fInfo.IsIgnored && ignoreGit {
541495
continue
542496
} else {
543497
filesInfo = append(filesInfo, fInfo)

src/install/default.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ main() {
528528
local autocomplete_install_rcode
529529

530530
croc_bin_name="croc"
531-
croc_version="10.2.0"
531+
croc_version="10.2.1"
532532
croc_dl_ext="tar.gz"
533533
croc_base_url="https://github.com/schollz/croc/releases/download"
534534
prefix="${1}"

0 commit comments

Comments
 (0)