(cmd *cobra.Command, args []string)
| 42 | } |
| 43 | |
| 44 | func dedupCommand(cmd *cobra.Command, args []string) { |
| 45 | if dedupFlags.test { |
| 46 | dedupTestCommand(cmd, args) |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | setupRepository() |
| 51 | if gitDir, err := git.GitDir(); err != nil { |
| 52 | ExitWithError(err) |
| 53 | } else if supported, err := tools.CheckCloneFileSupported(gitDir); err != nil || !supported { |
| 54 | Exit(tr.Tr.Get("This system does not support de-duplication.")) |
| 55 | } |
| 56 | |
| 57 | if len(cfg.Extensions()) > 0 { |
| 58 | Exit(tr.Tr.Get("This platform supports file de-duplication, however, Git LFS extensions are configured and therefore de-duplication can not be used.")) |
| 59 | } |
| 60 | |
| 61 | if dirty, err := git.IsWorkingCopyDirty(); err != nil { |
| 62 | ExitWithError(err) |
| 63 | } else if dirty { |
| 64 | Exit(tr.Tr.Get("Working tree is dirty. Please commit or reset your change.")) |
| 65 | } |
| 66 | |
| 67 | // We assume working tree is clean. |
| 68 | gitScanner := lfs.NewGitScanner(config.New(), func(p *lfs.WrappedPointer, err error) { |
| 69 | if err != nil { |
| 70 | Exit(tr.Tr.Get("Could not scan for Git LFS tree: %s", err)) |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | if success, err := dedup(p); err != nil { |
| 75 | // TRANSLATORS: Leading spaces should be included on |
| 76 | // the second line so the format specifier aligns with |
| 77 | // with the first format specifier on the first line. |
| 78 | Error(tr.Tr.Get("Skipped: %s (Size: %d)\n %s", p.Name, p.Size, err)) |
| 79 | } else if !success { |
| 80 | Error(tr.Tr.Get("Skipped: %s (Size: %d)", p.Name, p.Size)) |
| 81 | } else if success { |
| 82 | Print(tr.Tr.Get("Success: %s (Size: %d)", p.Name, p.Size)) |
| 83 | |
| 84 | atomic.AddInt64(&dedupStats.totalProcessedCount, 1) |
| 85 | atomic.AddInt64(&dedupStats.totalProcessedSize, p.Size) |
| 86 | } |
| 87 | }) |
| 88 | |
| 89 | if err := gitScanner.ScanTree("HEAD", nil); err != nil { |
| 90 | ExitWithError(err) |
| 91 | } |
| 92 | |
| 93 | // TRANSLATORS: The second and third strings should have the colons |
| 94 | // aligned in a column. |
| 95 | Print("\n\n%s\n %s\n %s", tr.Tr.Get("Finished successfully."), |
| 96 | tr.Tr.GetN( |
| 97 | "De-duplicated size: %d byte", |
| 98 | "De-duplicated size: %d bytes", |
| 99 | int(dedupStats.totalProcessedSize), |
| 100 | dedupStats.totalProcessedSize), |
| 101 | tr.Tr.Get(" count: %d", dedupStats.totalProcessedCount)) |
nothing calls this directly
no test coverage detected