Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Dec 31, 2024
1 parent dfcd032 commit e8758f6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg"
width="408px" border="0" alt="croc">
<br>
<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>
<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>
<a href="https://github.com/schollz/croc/actions/workflows/ci.yml"><img
src="https://github.com/schollz/croc/actions/workflows/ci.yml/badge.svg" alt="Build
Status"></a>
Expand Down
47 changes: 45 additions & 2 deletions src/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Run() (err error) {
app := cli.NewApp()
app.Name = "croc"
if Version == "" {
Version = "v10.2.0"
Version = "v10.2.1"
}
app.Version = Version
app.Compiled = time.Now()
Expand Down Expand Up @@ -431,6 +431,49 @@ Or you can go back to the classic croc behavior by enabling classic mode:
if err != nil {
return
}
minimalFileInfosInclude := []croc.FileInfo{}
exclusions := []string{}
for _, exclude := range crocOptions.Exclude {
exclusions = append(exclusions, strings.ToLower(exclude))
}
for _, f := range minimalFileInfos {
exclude := false
for _, exclusion := range exclusions {
if strings.Contains(path.Join(strings.ToLower(f.FolderRemote), strings.ToLower(f.Name)), exclusion) {
exclude = true
break
}
}
if !exclude {
minimalFileInfosInclude = append(minimalFileInfosInclude, f)
}
}
emptyFoldersToTransferInclude := []croc.FileInfo{}
for _, f := range emptyFoldersToTransfer {
exclude := false
for _, exclusion := range exclusions {
if strings.Contains(path.Join(strings.ToLower(f.FolderRemote), strings.ToLower(f.Name)), exclusion) {
exclude = true
break
}
}
if !exclude {
emptyFoldersToTransferInclude = append(emptyFoldersToTransferInclude, f)
}
}

totalNumberFolders = 0
folderMap := make(map[string]bool)
for _, f := range minimalFileInfosInclude {
folderMap[f.FolderRemote] = true
log.Tracef("zxvc file: %+v", f)
// is folder
}
for _, f := range emptyFoldersToTransferInclude {
log.Tracef("zxvc folder: %+v", f)
}
totalNumberFolders = len(folderMap)
log.Debugf("zxvc total number of folders: %d", totalNumberFolders)

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

err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders)
err = cr.Send(minimalFileInfosInclude, emptyFoldersToTransferInclude, totalNumberFolders)

return
}
Expand Down
50 changes: 2 additions & 48 deletions src/croc/croc.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,21 +423,6 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
TempFile: true,
IsIgnored: ignoredPaths[absPath],
}
// check if exclusions apply to this file
if len(exclusions) > 0 && !fInfo.IsIgnored {
allFiles, _ := recursiveFiles(absPath)
for _, exclusion := range exclusions {
for _, file := range allFiles {
if strings.Contains(strings.ToLower(file), strings.ToLower(exclusion)) {
fInfo.IsIgnored = true
break
}
}
if fInfo.IsIgnored {
break
}
}
}
if fInfo.IsIgnored {
continue
}
Expand Down Expand Up @@ -470,23 +455,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
TempFile: false,
IsIgnored: ignoredPaths[pathName],
}
// check if exclusions apply to this file
if len(exclusions) > 0 && !fInfo.IsIgnored {
allFiles, _ := recursiveFiles(pathName)
for _, exclusion := range exclusions {
for _, file := range allFiles {
log.Tracef("ignoring test: %s %s %v", strings.ToLower(file), strings.ToLower(exclusion), strings.Contains(strings.ToLower(file), strings.ToLower(exclusion)))
if strings.Contains(strings.ToLower(file), strings.ToLower(exclusion)) {
fInfo.IsIgnored = true
break
}
}
if fInfo.IsIgnored {
break
}
}
}
if fInfo.IsIgnored && (ignoreGit || len(exclusions) > 0) {
if fInfo.IsIgnored && ignoreGit {
return nil
} else {
filesInfo = append(filesInfo, fInfo)
Expand Down Expand Up @@ -522,22 +491,7 @@ func GetFilesInfo(fnames []string, zipfolder bool, ignoreGit bool, exclusions []
TempFile: false,
IsIgnored: ignoredPaths[absPath],
}
if len(exclusions) > 0 && !fInfo.IsIgnored {
allFiles, _ := recursiveFiles(absPath)
for _, exclusion := range exclusions {
for _, file := range allFiles {
log.Tracef("ignoring test: %s %s %v", strings.ToLower(file), strings.ToLower(exclusion), strings.Contains(strings.ToLower(file), strings.ToLower(exclusion)))
if strings.Contains(strings.ToLower(file), strings.ToLower(exclusion)) {
fInfo.IsIgnored = true
break
}
}
if fInfo.IsIgnored {
break
}
}
}
if fInfo.IsIgnored && (ignoreGit || len(exclusions) > 0) {
if fInfo.IsIgnored && ignoreGit {
continue
} else {
filesInfo = append(filesInfo, fInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/install/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ main() {
local autocomplete_install_rcode

croc_bin_name="croc"
croc_version="10.2.0"
croc_version="10.2.1"
croc_dl_ext="tar.gz"
croc_base_url="https://github.com/schollz/croc/releases/download"
prefix="${1}"
Expand Down

0 comments on commit e8758f6

Please sign in to comment.