Skip to content

Commit b25a571

Browse files
lunnyKN4CK3Rwxiaoguang
authored
Set HeadCommit when creating tags. (#18116) (#18173)
Co-authored-by: KN4CK3R <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent f9bbed0 commit b25a571

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

services/release/release.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ func createTag(gitRepo *git.Repository, rel *models.Release, msg string) (bool,
6969
created = true
7070
rel.LowerTagName = strings.ToLower(rel.TagName)
7171

72+
commits := repository.NewPushCommits()
73+
commits.HeadCommit = repository.CommitToPushCommit(commit)
74+
commits.CompareURL = rel.Repo.ComposeCompareURL(git.EmptySHA, commit.ID.String())
75+
7276
notification.NotifyPushCommits(
7377
rel.Publisher, rel.Repo,
7478
&repository.PushUpdateOptions{
7579
RefFullName: git.TagPrefix + rel.TagName,
7680
OldCommitID: git.EmptySHA,
7781
NewCommitID: commit.ID.String(),
78-
}, repository.NewPushCommits())
82+
}, commits)
7983
notification.NotifyCreateRef(rel.Publisher, rel.Repo, "tag", git.TagPrefix+rel.TagName)
8084
rel.CreatedUnix = timeutil.TimeStampNow()
8185
}

services/repository/push.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,22 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
115115
delTags = append(delTags, tagName)
116116
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
117117
} else { // is new tag
118+
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
119+
if err != nil {
120+
return fmt.Errorf("gitRepo.GetCommit: %v", err)
121+
}
122+
123+
commits := repo_module.NewPushCommits()
124+
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
125+
commits.CompareURL = repo.ComposeCompareURL(git.EmptySHA, opts.NewCommitID)
126+
118127
notification.NotifyPushCommits(
119128
pusher, repo,
120129
&repo_module.PushUpdateOptions{
121130
RefFullName: git.TagPrefix + tagName,
122131
OldCommitID: git.EmptySHA,
123132
NewCommitID: opts.NewCommitID,
124-
}, repo_module.NewPushCommits())
133+
}, commits)
125134

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

0 commit comments

Comments
 (0)