Skip to content

Commit

Permalink
Convert github release commitish during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
harryzcy committed Jul 23, 2022
1 parent e4aedf2 commit ba30dbd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/migrations/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strings"
"time"

"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/proxy"
Expand Down Expand Up @@ -291,10 +292,14 @@ func (g *GithubDownloaderV3) GetLabels() ([]*base.Label, error) {
}

func (g *GithubDownloaderV3) convertGithubRelease(rel *github.RepositoryRelease) *base.Release {
// GitHub allows commitish to be a reference.
// In this case, we need to remove the prefix, i.e. convert "refs/heads/main" to "main".
targetCommitish := strings.TrimPrefix(rel.GetTargetCommitish(), git.BranchPrefix)

r := &base.Release{
Name: rel.GetName(),
TagName: rel.GetTagName(),
TargetCommitish: rel.GetTargetCommitish(),
TargetCommitish: targetCommitish,
Draft: rel.GetDraft(),
Prerelease: rel.GetPrerelease(),
Created: rel.GetCreatedAt().Time,
Expand Down

0 comments on commit ba30dbd

Please sign in to comment.