diff --git a/README.md b/README.md index a91c0fbce..316433153 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ src="https://user-images.githubusercontent.com/6550035/46709024-9b23ad00-cbf6-11e8-9fb2-ca8b20b7dbec.jpg" width="408px" border="0" alt="croc">
-Version +Version Build
 Status diff --git a/src/cli/cli.go b/src/cli/cli.go index e8ec3ba6f..a4c0495f4 100644 --- a/src/cli/cli.go +++ b/src/cli/cli.go @@ -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() @@ -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 { @@ -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 } diff --git a/src/croc/croc.go b/src/croc/croc.go index de846e8e9..65f550bf7 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -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 } @@ -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) @@ -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) diff --git a/src/install/default.txt b/src/install/default.txt index 9a4063b89..664ce14d9 100644 --- a/src/install/default.txt +++ b/src/install/default.txt @@ -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}"