MCPcopy Create free account
hub / github.com/git-bug/git-bug / GetOrCreateClock

Method GetOrCreateClock

repository/gogit.go:863–882  ·  view source on GitHub ↗

GetOrCreateClock return a Lamport clock stored in the Repo. If the clock doesn't exist, it's created.

(name string)

Source from the content-addressed store, hash-verified

861// GetOrCreateClock return a Lamport clock stored in the Repo.
862// If the clock doesn't exist, it's created.
863func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) {
864 repo.clocksMutex.Lock()
865 defer repo.clocksMutex.Unlock()
866
867 c, err := repo.getClock(name)
868 if err == nil {
869 return c, nil
870 }
871 if err != ErrClockNotExist {
872 return nil, err
873 }
874
875 c, err = lamport.NewPersistedClock(repo.LocalStorage(), filepath.Join(clockPath, name))
876 if err != nil {
877 return nil, err
878 }
879
880 repo.clocks[name] = c
881 return c, nil
882}
883
884func (repo *GoGitRepo) getClock(name string) (lamport.Clock, error) {
885 if c, ok := repo.clocks[name]; ok {

Callers 2

IncrementMethod · 0.95
WitnessMethod · 0.95

Calls 4

getClockMethod · 0.95
LocalStorageMethod · 0.95
NewPersistedClockFunction · 0.92
LockMethod · 0.65

Tested by

no test coverage detected