mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
The cached git config runs its `git config` reads through raw exec.Command calls, outside the pinned git command builder, so they followed the process working directory. A cache miss on a stale instance — one still in use by a refresh that crossed a repo switch — would therefore read the new repo's local config while computing data for the old one. Give the cache a directory, set once by NewGitCommand right after it determines the repo paths (the object is created fresh for every repo switch, so no cross-repo cache invalidation is needed), and run every config command there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
678 B
Go
36 lines
678 B
Go
package git_config
|
|
|
|
type FakeGitConfig struct {
|
|
mockResponses map[string]string
|
|
}
|
|
|
|
func NewFakeGitConfig(mockResponses map[string]string) *FakeGitConfig {
|
|
return &FakeGitConfig{
|
|
mockResponses: mockResponses,
|
|
}
|
|
}
|
|
|
|
func (self *FakeGitConfig) Get(key string) string {
|
|
if self.mockResponses == nil {
|
|
return ""
|
|
}
|
|
return self.mockResponses[key]
|
|
}
|
|
|
|
func (self *FakeGitConfig) GetGeneral(args string) string {
|
|
if self.mockResponses == nil {
|
|
return ""
|
|
}
|
|
return self.mockResponses[args]
|
|
}
|
|
|
|
func (self *FakeGitConfig) GetBool(key string) bool {
|
|
return isTruthy(self.Get(key))
|
|
}
|
|
|
|
func (self *FakeGitConfig) SetDir(dir string) {
|
|
}
|
|
|
|
func (self *FakeGitConfig) DropCache() {
|
|
}
|