Skip to content

Commit ba30dbd

Browse files
committed
Convert github release commitish during migration
1 parent e4aedf2 commit ba30dbd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

services/migrations/github.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"strings"
1616
"time"
1717

18+
"code.gitea.io/gitea/modules/git"
1819
"code.gitea.io/gitea/modules/log"
1920
base "code.gitea.io/gitea/modules/migration"
2021
"code.gitea.io/gitea/modules/proxy"
@@ -291,10 +292,14 @@ func (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error) {
291292
}
292293

293294
func (g *GithubDownloaderV3) convertGithubRelease(rel *github.RepositoryRelease) *base.Release {
295+
// GitHub allows commitish to be a reference.
296+
// In this case, we need to remove the prefix, i.e. convert "refs/heads/main" to "main".
297+
targetCommitish := strings.TrimPrefix(rel.GetTargetCommitish(), git.BranchPrefix)
298+
294299
r := &base.Release{
295300
Name: rel.GetName(),
296301
TagName: rel.GetTagName(),
297-
TargetCommitish: rel.GetTargetCommitish(),
302+
TargetCommitish: targetCommitish,
298303
Draft: rel.GetDraft(),
299304
Prerelease: rel.GetPrerelease(),
300305
Created: rel.GetCreatedAt().Time,

0 commit comments

Comments
 (0)