func pruneCheckVerified(prunableObjects []string, reachableObjects, verifiedObjects lfs.StringSet) { // There's no issue if an object is not reachable and missing, only if reachable & missing var problems bytes.Buffer for _, oid := range prunableObjects { // Test verified first as most likely reachable if !verifiedObjects.Contains(oid) { if reachableObjects.Contains(oid) { problems.WriteString(fmt.Sprintf(" * %v\n", oid)) } else { // Just to indicate why it doesn't matter that we didn't verify tracerx.Printf("UNREACHABLE: %v", oid) } } } // technically we could still prune the other oids, but this indicates a // more serious issue because the local state implies that these can be // deleted but that's incorrect; bad state has occurred somehow, might need // push --all to resolve if problems.Len() > 0 { Exit("Abort: these objects to be pruned are missing on remote:\n%v", problems.String()) } }
func prePushRef(left, right string) { // Just use scanner here scanOpt := lfs.NewScanRefsOptions() scanOpt.ScanMode = lfs.ScanLeftToRemoteMode scanOpt.RemoteName = lfs.Config.CurrentRemote pointers, err := lfs.ScanRefs(left, right, scanOpt) if err != nil { Panic(err, "Error scanning for Git LFS files") } totalSize := int64(0) for _, p := range pointers { totalSize += p.Size } // Objects to skip because they're missing locally but on server var skipObjects lfs.StringSet if !prePushDryRun { // Do this as a pre-flight check since upload queue starts immediately skipObjects = prePushCheckForMissingObjects(pointers) } uploadQueue := lfs.NewUploadQueue(len(pointers), totalSize, prePushDryRun) for _, pointer := range pointers { if prePushDryRun { Print("push %s => %s", pointer.Oid, pointer.Name) continue } if skipObjects.Contains(pointer.Oid) { // object missing locally but on server, don't bother continue } u, err := lfs.NewUploadable(pointer.Oid, pointer.Name) if err != nil { if lfs.IsCleanPointerError(err) { Exit(prePushMissingErrMsg, pointer.Name, lfs.ErrorGetContext(err, "pointer").(*lfs.Pointer).Oid) } else if Debugging || lfs.IsFatalError(err) { Panic(err, err.Error()) } else { Exit(err.Error()) } } uploadQueue.Add(u) } if !prePushDryRun { uploadQueue.Wait() for _, err := range uploadQueue.Errors() { if Debugging || lfs.IsFatalError(err) { LoggedError(err, err.Error()) } else { Error(err.Error()) } } if len(uploadQueue.Errors()) > 0 { os.Exit(2) } } }