(cmd *cobra.Command, args []string)
| 25 | ) |
| 26 | |
| 27 | func pointerCommand(cmd *cobra.Command, args []string) { |
| 28 | comparing := false |
| 29 | something := false |
| 30 | buildOid := "" |
| 31 | compareOid := "" |
| 32 | |
| 33 | if pointerCheck { |
| 34 | var r io.ReadCloser |
| 35 | var err error |
| 36 | |
| 37 | if pointerStrict && pointerNoStrict { |
| 38 | ExitWithError(errors.New(tr.Tr.Get("Cannot combine --strict with --no-strict"))) |
| 39 | } |
| 40 | |
| 41 | if len(pointerCompare) > 0 { |
| 42 | ExitWithError(errors.New(tr.Tr.Get("Cannot combine --check with --compare"))) |
| 43 | } |
| 44 | |
| 45 | if len(pointerFile) > 0 { |
| 46 | if pointerStdin { |
| 47 | ExitWithError(errors.New(tr.Tr.Get("With --check, --file cannot be combined with --stdin"))) |
| 48 | } |
| 49 | r, err = os.Open(pointerFile) |
| 50 | if err != nil { |
| 51 | ExitWithError(err) |
| 52 | } |
| 53 | } else if pointerStdin { |
| 54 | r = io.NopCloser(os.Stdin) |
| 55 | } else { |
| 56 | ExitWithError(errors.New(tr.Tr.Get("Must specify either --file or --stdin with --compare"))) |
| 57 | } |
| 58 | |
| 59 | p, err := lfs.DecodePointer(r) |
| 60 | if err != nil { |
| 61 | os.Exit(1) |
| 62 | } |
| 63 | if pointerStrict && !p.Canonical { |
| 64 | os.Exit(2) |
| 65 | } |
| 66 | r.Close() |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | if len(pointerCompare) > 0 || pointerStdin { |
| 71 | comparing = true |
| 72 | } |
| 73 | |
| 74 | if len(pointerFile) > 0 { |
| 75 | something = true |
| 76 | buildFile, err := os.Open(pointerFile) |
| 77 | if err != nil { |
| 78 | Error(err.Error()) |
| 79 | os.Exit(1) |
| 80 | } |
| 81 | |
| 82 | oidHash := sha256.New() |
| 83 | size, err := io.Copy(oidHash, buildFile) |
| 84 | buildFile.Close() |
nothing calls this directly
no test coverage detected