Skip to content

Commit e2e95e9

Browse files
fix: 🩹 perform git fetch command inside the retry function
1 parent 9ebbaf6 commit e2e95e9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

pkg/sync/sync.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ func CloneOrUpdateRepo(repoOwner, repoName string, config config.Config) {
7373

7474
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
7575
logger.Info("Cloning repo: ", repoFullName)
76-
command := getGitCloneCommand(config.CloneType, repoPath, repoURL)
7776

7877
err := retryOperation(config, func() error {
78+
command := getGitCloneCommand(config.CloneType, repoPath, repoURL)
7979
output, err := command.CombinedOutput()
8080
logger.Debugf("Output: %s\n", output)
8181
return err
@@ -91,9 +91,9 @@ func CloneOrUpdateRepo(repoOwner, repoName string, config config.Config) {
9191
recordRepoSuccess()
9292
} else {
9393
logger.Info("Updating repo: ", repoFullName)
94-
command := getGitFetchCommand(config.CloneType, repoPath, repoURL)
9594

9695
err := retryOperation(config, func() error {
96+
command := getGitFetchCommand(config.CloneType, repoPath, repoURL)
9797
output, err := command.CombinedOutput()
9898
logger.Debugf("Output: %s\n", output)
9999
return err
@@ -115,9 +115,9 @@ func CloneOrUpdateRawRepo(repoOwner, repoName, repoURL string, config config.Con
115115

116116
if _, err := os.Stat(repoPath); os.IsNotExist(err) {
117117
logger.Info("Cloning raw repo: ", repoURL)
118-
command := getGitCloneCommand(config.CloneType, repoPath, repoURL)
119118

120119
err := retryOperation(config, func() error {
120+
command := getGitCloneCommand(config.CloneType, repoPath, repoURL)
121121
output, err := command.CombinedOutput()
122122
logger.Debugf("Output: %s\n", output)
123123
return err
@@ -133,9 +133,9 @@ func CloneOrUpdateRawRepo(repoOwner, repoName, repoURL string, config config.Con
133133
recordRepoSuccess()
134134
} else {
135135
logger.Info("Updating raw repo: ", repoURL)
136-
command := getGitFetchCommand(config.CloneType, repoPath, repoURL)
137136

138137
err := retryOperation(config, func() error {
138+
command := getGitFetchCommand(config.CloneType, repoPath, repoURL)
139139
output, err := command.CombinedOutput()
140140
logger.Debugf("Output: %s\n", output)
141141
return err
@@ -169,10 +169,10 @@ func SyncWiki(repoOwner, repoName string, config config.Config) {
169169

170170
if _, err := os.Stat(repoWikiPath); os.IsNotExist(err) {
171171
logger.Info("Cloning wiki: ", repoFullName)
172-
command := exec.Command("git", "clone", repoWikiURL, repoWikiPath)
173172
wikiNotFound := false
174173

175174
err := retryOperation(config, func() error {
175+
command := exec.Command("git", "clone", repoWikiURL, repoWikiPath)
176176
output, err := command.CombinedOutput()
177177
logger.Debugf("Output: %s\n", output)
178178
if err != nil && strings.Contains(string(output), "not found") {
@@ -197,9 +197,9 @@ func SyncWiki(repoOwner, repoName string, config config.Config) {
197197
}
198198
} else {
199199
logger.Info("Updating wiki: ", repoFullName)
200-
command := exec.Command("git", "-C", repoWikiPath, "pull", "--prune", "origin")
201200

202201
err := retryOperation(config, func() error {
202+
command := exec.Command("git", "-C", repoWikiPath, "pull", "--prune", "origin")
203203
output, err := command.CombinedOutput()
204204
logger.Debugf("Output: %s\n", output)
205205
return err

0 commit comments

Comments
 (0)