Skip to content

Commit

Permalink
Set HeadCommit when creating tags. (go-gitea#18116)
Browse files Browse the repository at this point in the history
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
2 people authored and lunny committed Jan 4, 2022
1 parent f9bbed0 commit de96f5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion services/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@ func createTag(gitRepo *git.Repository, rel *models.Release, msg string) (bool,
created = true
rel.LowerTagName = strings.ToLower(rel.TagName)

commits := repository.NewPushCommits()
commits.HeadCommit = repository.CommitToPushCommit(commit)
commits.CompareURL = rel.Repo.ComposeCompareURL(git.EmptySHA, commit.ID.String())

notification.NotifyPushCommits(
rel.Publisher, rel.Repo,
&repository.PushUpdateOptions{
RefFullName: git.TagPrefix + rel.TagName,
OldCommitID: git.EmptySHA,
NewCommitID: commit.ID.String(),
}, repository.NewPushCommits())
}, commits)
notification.NotifyCreateRef(rel.Publisher, rel.Repo, "tag", git.TagPrefix+rel.TagName)
rel.CreatedUnix = timeutil.TimeStampNow()
}
Expand Down
11 changes: 10 additions & 1 deletion services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,22 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
delTags = append(delTags, tagName)
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
} else { // is new tag
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
if err != nil {
return fmt.Errorf("gitRepo.GetCommit: %v", err)
}

commits := repo_module.NewPushCommits()
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
commits.CompareURL = repo.ComposeCompareURL(git.EmptySHA, opts.NewCommitID)

notification.NotifyPushCommits(
pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: git.EmptySHA,
NewCommitID: opts.NewCommitID,
}, repo_module.NewPushCommits())
}, commits)

addTags = append(addTags, tagName)
notification.NotifyCreateRef(pusher, repo, "tag", opts.RefFullName)
Expand Down

0 comments on commit de96f5f

Please sign in to comment.