sourcehut: use ssh sources URL when appropriate

Co-authored-by: Jordan Anderson <jordan@jba.io>
This commit is contained in:
oliverpool 2025-01-01 11:40:41 +01:00
parent 6e13ac4d5f
commit 3bea06f906
2 changed files with 59 additions and 3 deletions

View file

@ -289,16 +289,21 @@ func adjustManifest(repo *api.Repository, commitID, gitRef string, r io.Reader,
manifest.Environment["BUILD_SUBMITTER_URL"] = setting.AppURL
manifest.Environment["GIT_REF"] = gitRef
source := repo.CloneURL + "#" + commitID
found := false
for i, s := range manifest.Sources {
if s == repo.CloneURL {
manifest.Sources[i] = source
if s == repo.CloneURL || s == repo.SSHURL {
manifest.Sources[i] = s + "#" + commitID
found = true
break
}
}
if !found {
source := repo.CloneURL
if repo.Private || setting.Repository.DisableHTTPGit {
// default to ssh for private repos or when git clone is disabled over http
source = repo.SSHURL
}
source += "#" + commitID
manifest.Sources = append(manifest.Sources, source)
}