fix(stack/git): clone to non-version project path during auto update

fix/EE-5980/version-stack-backward-capability
oscarzhou 1 year ago
parent 748c6fa22a
commit 2bfb4c0e25

@ -48,10 +48,6 @@ func UpdateGitObject(gitService portainer.GitService, objId string, gitConfig *g
}
toDir := projectPath
if enableVersionFolder {
toDir = filesystem.JoinPaths(projectPath, newHash)
}
cloneParams := &cloneRepositoryParameters{
url: gitConfig.URL,
ref: gitConfig.ReferenceName,
@ -65,10 +61,20 @@ func UpdateGitObject(gitService portainer.GitService, objId string, gitConfig *g
}
}
// For backward compatibility, we need to clone the repository in the old project path
if err := cloneGitRepository(gitService, cloneParams); err != nil {
return false, "", errors.WithMessagef(err, "failed to do a fresh clone of %v", objId)
}
if enableVersionFolder {
toDir = filesystem.JoinPaths(projectPath, newHash)
cloneParams.toDir = toDir
if err := cloneGitRepository(gitService, cloneParams); err != nil {
return false, "", errors.WithMessagef(err, "failed to do a fresh clone of %v", objId)
}
}
log.Debug().
Str("hash", newHash).
Str("url", gitConfig.URL).

Loading…
Cancel
Save