Skip to content

generic: Swap out `CommandFactory` with `RepositoryExecutor`

Currently, in many places of our codebase, we interchangeably use CommandFactory.New and RepositoryExecutor.Exec. The latter is just a wrapper which eventually calls CommandFactory.New.

But there is benefit to using RepositoryExecutor, for one it ensures consistency everywhere and since RepositoryExecutor is an interface, it ensures good abstraction. But more importantly, its implementation is localrepo.Repo which provides caching for repository related Git operations. Specifically, the ObjectHash and ReferenceBackend detection. These operations were generally done by calling gitcmd.DetectReferenceBackend and gitcmd.DetectObjectHash. Both don't provide any caching and called multiple times through the code base. Consequence of which being: Object Hash detection takes 3.5% of Gitaly CPU ... (#6318 - closed).

This MR consolidates the behavior to use RepositoryExecutor.Exec everywhere throughout the codebase. This is also a precursor to adding reference backend as a label to our Git command metrics.

Edited by Karthik Nayak

Merge request reports

Loading