Skip to content

Commit

Permalink
Support using both remote repos and a persistent clone
Browse files Browse the repository at this point in the history
  • Loading branch information
bpineau committed Jul 28, 2019
1 parent 929386f commit 5596a90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/recorder/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (w *Listener) deleteObsoleteFiles() {
root := filepath.Clean(w.localDir)

err := afero.Walk(appFs, root, func(path string, info os.FileInfo, err error) error {
if info == nil {
return fmt.Errorf("can't stat %s", path)
}

if info.IsDir() {
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/store/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ func (s *Store) CloneOrInit() (err error) {
}
}

// One may both sync with a remote repos and keep a persistent local clone
if _, err := os.Stat(fmt.Sprintf("%s/.git/index", s.LocalDir)); err == nil {
return nil
}

if s.URL == "" {
err = s.Git("init", s.LocalDir)
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func TestGit(t *testing.T) {
// test various failure modes

_, err = repo.Start()
if err == nil {
t.Error("Start/Clone on an existing repository should fail")
if err != nil {
t.Error("Start/Clone on an existing repository should not fail")
}

err = repo.Git("fortzob", "42")
Expand Down

0 comments on commit 5596a90

Please sign in to comment.