Skip to content

Commit 3b728ab

Browse files
committed
fix: clone repo when clone-path exists but is not a git repository
1 parent 88d383e commit 3b728ab

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

pkg/lib/git-runner.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ func NewGitRunner(origin, path string, fetchInterval int) *GitRunner {
2727
}
2828
}
2929

30-
// Init checks, if the local repository exists, if not clones it.
31-
// If it does exist, it updates it.
30+
// Init checks if the local path is a valid git repository.
31+
// If not (missing, empty, or non-git directory), it clones fresh.
32+
// If it is, it pulls the latest changes.
3233
func (gr *GitRunner) Init() error {
33-
// Try to open as a valid git repository
3434
if _, err := git.PlainOpen(gr.LocalPath); err == nil {
35-
// Repo exists and is valid — update it
3635
Logger.Info("Update", "origin", gr.origin)
3736
if err = gr.updateRepo(); err != nil {
3837
return err
@@ -41,7 +40,6 @@ func (gr *GitRunner) Init() error {
4140
return err
4241
}
4342

44-
// Not a valid git repo (directory missing, empty, or corrupted) — clone fresh
4543
Logger.Info("Cloning", "origin", gr.origin, "path", gr.LocalPath)
4644

4745
// Remove the path if it already exists (handles empty Docker volume mount)

0 commit comments

Comments
 (0)