From 63c48eb075a0986f384d00566193b282576774cb Mon Sep 17 00:00:00 2001 From: John Cai Date: Wed, 9 Jul 2025 15:46:21 -0400 Subject: [PATCH] manager: Remove remaining usages of pack refs inhibitor logic --- internal/git/housekeeping/manager/manager.go | 34 ------------------- .../manager/optimize_repository.go | 7 ---- 2 files changed, 41 deletions(-) diff --git a/internal/git/housekeeping/manager/manager.go b/internal/git/housekeeping/manager/manager.go index 7f42dbf70d..306f637f10 100644 --- a/internal/git/housekeeping/manager/manager.go +++ b/internal/git/housekeeping/manager/manager.go @@ -39,8 +39,6 @@ type repositoryState struct { // packRefsDone is a channel used to denote when the ongoing (if any) call to packRefsIfNeeded // is completed. packRefsDone chan struct{} - // packRefsInhibitors keeps a count of the number of inhibitors on running packRefsIfNeeded. - packRefsInhibitors int32 // isRunning is used to indicate if housekeeping is running. isRunning bool } @@ -127,38 +125,6 @@ func (s *repositoryStates) tryRunningHousekeeping(repo storage.Repository) (succ } } -// tryRunningPackRefs checks if we can run `git-pack-refs(1)` for a given repository. If there -// is at least one inhibitors then we return false. If there are no inhibitors, we setup the `packRefsDone` -// channel to denote when `git-pack-refs(1)` finishes, this is handled when the caller calls the -// cleanup function returned by this function. -func (s *repositoryStates) tryRunningPackRefs(repo storage.Repository) (successful bool, _ func()) { - state, cleanup := s.getState(repo) - defer func() { - if !successful { - cleanup() - } - }() - - state.Lock() - defer state.Unlock() - - if state.packRefsInhibitors > 0 || state.packRefsDone != nil { - return false, nil - } - - state.packRefsDone = make(chan struct{}) - - return true, func() { - defer cleanup() - - state.Lock() - defer state.Unlock() - - close(state.packRefsDone) - state.packRefsDone = nil - } -} - // RepositoryManager is an implementation of the Manager interface. type RepositoryManager struct { logger log.Logger diff --git a/internal/git/housekeeping/manager/optimize_repository.go b/internal/git/housekeeping/manager/optimize_repository.go index f9bdd020ab..bc8ef1fa0f 100644 --- a/internal/git/housekeeping/manager/optimize_repository.go +++ b/internal/git/housekeeping/manager/optimize_repository.go @@ -437,13 +437,6 @@ func (m *RepositoryManager) packRefsIfNeeded(ctx context.Context, repo *localrep return false, nil } - // If there are any inhibitors, we don't run git-pack-refs(1). - ok, cleanup := m.repositoryStates.tryRunningPackRefs(repo) - if !ok { - return false, nil - } - defer cleanup() - var stderr bytes.Buffer if err := repo.ExecAndWait(ctx, gitcmd.Command{ Name: "pack-refs", -- GitLab