Background task, must call waitg.Done() once at end
(gitscanner *lfs.GitScanner, fetchconf lfs.FetchPruneConfig, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted)
| 429 | |
| 430 | // Background task, must call waitg.Done() once at end |
| 431 | func pruneTaskGetRetainedCurrentAndRecentRefs(gitscanner *lfs.GitScanner, fetchconf lfs.FetchPruneConfig, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted) { |
| 432 | defer waitg.Done() |
| 433 | |
| 434 | // We actually increment the waitg in this func since we kick off sub-goroutines |
| 435 | // Make a list of what unique commits to keep, & search backward from |
| 436 | commits := tools.NewStringSet() |
| 437 | // Do current first |
| 438 | ref, err := git.CurrentRef() |
| 439 | if err != nil { |
| 440 | errorChan <- err |
| 441 | return |
| 442 | } |
| 443 | commits.Add(ref.Sha) |
| 444 | if !fetchconf.PruneForce { |
| 445 | waitg.Add(1) |
| 446 | go pruneTaskGetRetainedAtRef(gitscanner, ref.Sha, retainChan, errorChan, waitg, sem) |
| 447 | } |
| 448 | |
| 449 | // Now recent |
| 450 | if !fetchconf.PruneRecent && fetchconf.FetchRecentRefsDays > 0 { |
| 451 | pruneRefDays := fetchconf.FetchRecentRefsDays + fetchconf.PruneOffsetDays |
| 452 | tracerx.Printf("PRUNE: Retaining non-HEAD refs within %d (%d+%d) days", pruneRefDays, fetchconf.FetchRecentRefsDays, fetchconf.PruneOffsetDays) |
| 453 | refsSince := time.Now().AddDate(0, 0, -pruneRefDays) |
| 454 | // Keep all recent refs including any recent remote branches |
| 455 | refs, err := git.RecentBranches(refsSince, fetchconf.FetchRecentRefsIncludeRemotes, "") |
| 456 | if err != nil { |
| 457 | Panic(err, tr.Tr.Get("Could not scan for recent refs")) |
| 458 | } |
| 459 | for _, ref := range refs { |
| 460 | if commits.Add(ref.Sha) { |
| 461 | // A new commit |
| 462 | waitg.Add(1) |
| 463 | go pruneTaskGetRetainedAtRef(gitscanner, ref.Sha, retainChan, errorChan, waitg, sem) |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | // For every unique commit we've fetched, check recent commits too |
| 469 | // Only if we're fetching recent commits, otherwise only keep at refs |
| 470 | if !fetchconf.PruneRecent && fetchconf.FetchRecentCommitsDays > 0 { |
| 471 | pruneCommitDays := fetchconf.FetchRecentCommitsDays + fetchconf.PruneOffsetDays |
| 472 | for commit := range commits.Iter() { |
| 473 | // We measure from the last commit at the ref |
| 474 | summ, err := git.GetCommitSummary(commit) |
| 475 | if err != nil { |
| 476 | errorChan <- errors.New(tr.Tr.Get("couldn't scan commits at %v: %v", commit, err)) |
| 477 | continue |
| 478 | } |
| 479 | commitsSince := summ.CommitDate.AddDate(0, 0, -pruneCommitDays) |
| 480 | waitg.Add(1) |
| 481 | go pruneTaskGetPreviousVersionsOfRef(gitscanner, commit, commitsSince, retainChan, errorChan, waitg, sem) |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | // Background task, must call waitg.Done() once at end |
| 487 | func pruneTaskGetRetainedUnpushed(gitscanner *lfs.GitScanner, fetchconf lfs.FetchPruneConfig, retainChan chan string, errorChan chan error, waitg *sync.WaitGroup, sem *semaphore.Weighted) { |
no test coverage detected