Skip to content

Commit 5f30903

Browse files
authored
Merge pull request #58 from unity-sds/marketplace_auto_updates
Auto-updates marketplace items from the repo when they are installed.
2 parents 0ef7c06 + df2a363 commit 5f30903

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

backend/internal/processes/marketplace.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,30 @@ func gitClone(url string, basedir string) (string, error) {
9090
return "", err
9191
}
9292

93-
// If the repository already exists, open it
93+
// If the repository already exists, open it and pull the latest changes
9494
repo, err = git.PlainOpen(basedir)
9595
if err != nil {
9696
return "", err
9797
}
98+
99+
// Pull the latest changes
100+
log.Infof("Repository already exists, pulling latest changes in %s", basedir)
101+
w, err := repo.Worktree()
102+
if err != nil {
103+
log.Errorf("Couldn't get worktree: %v", err)
104+
return "", err
105+
}
106+
107+
err = w.Pull(&git.PullOptions{
108+
Progress: os.Stdout,
109+
})
110+
111+
if err != nil && err != git.NoErrAlreadyUpToDate {
112+
log.Errorf("Couldn't pull updates: %v", err)
113+
return "", err
114+
} else if err == git.NoErrAlreadyUpToDate {
115+
log.Infof("Repository already up to date")
116+
}
98117
}
99118

100119
// Checkout the specific SHA if provided

0 commit comments

Comments
 (0)