aboutsummaryrefslogtreecommitdiffstats
path: root/repository/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository/repo.go')
-rw-r--r--repository/repo.go54
1 files changed, 26 insertions, 28 deletions
diff --git a/repository/repo.go b/repository/repo.go
index e8517508..561fc1c5 100644
--- a/repository/repo.go
+++ b/repository/repo.go
@@ -13,6 +13,10 @@ import (
var (
ErrNoConfigEntry = errors.New("no config entry for the given key")
ErrMultipleConfigEntry = errors.New("multiple config entry for the given key")
+ // ErrNotARepo is the error returned when the git repo root wan't be found
+ ErrNotARepo = errors.New("not a git repository")
+ // ErrClockNotExist is the error returned when a clock can't be found
+ ErrClockNotExist = errors.New("clock doesn't exist")
)
// RepoConfig access the configuration of a repository
@@ -97,36 +101,22 @@ type Repo interface {
type ClockedRepo interface {
Repo
- // LoadClocks read the clocks values from the on-disk repo
- LoadClocks() error
-
- // WriteClocks write the clocks values into the repo
- WriteClocks() error
-
- // CreateTime return the current value of the creation clock
- CreateTime() lamport.Time
-
- // CreateTimeIncrement increment the creation clock and return the new value.
- CreateTimeIncrement() (lamport.Time, error)
-
- // EditTime return the current value of the edit clock
- EditTime() lamport.Time
-
- // EditTimeIncrement increment the edit clock and return the new value.
- EditTimeIncrement() (lamport.Time, error)
-
- // WitnessCreate witness another create time and increment the corresponding
- // clock if needed.
- WitnessCreate(time lamport.Time) error
-
- // WitnessEdit witness another edition time and increment the corresponding
- // clock if needed.
- WitnessEdit(time lamport.Time) error
+ // GetOrCreateClock return a Lamport clock stored in the Repo.
+ // If the clock doesn't exist, it's created.
+ GetOrCreateClock(name string) (lamport.Clock, error)
}
-// Witnesser is a function that will initialize the clocks of a repo
-// from scratch
-type Witnesser func(repo ClockedRepo) error
+// ClockLoader hold which logical clock need to exist for an entity and
+// how to create them if they don't.
+type ClockLoader struct {
+ // Clocks hold the name of all the clocks this loader deal with.
+ // Those clocks will be checked when the repo load. If not present or broken,
+ // Witnesser will be used to create them.
+ Clocks []string
+ // Witnesser is a function that will initialize the clocks of a repo
+ // from scratch
+ Witnesser func(repo ClockedRepo) error
+}
func prepareTreeEntries(entries []TreeEntry) bytes.Buffer {
var buffer bytes.Buffer
@@ -158,3 +148,11 @@ func readTreeEntries(s string) ([]TreeEntry, error) {
return casted, nil
}
+
+// TestedRepo is an extended ClockedRepo with function for testing only
+type TestedRepo interface {
+ ClockedRepo
+
+ // AddRemote add a new remote to the repository
+ AddRemote(name string, url string) error
+}