Skip to content

Commit 8fa97a2

Browse files
KN4CK3Rwxiaoguang
andauthored
Set HeadCommit when creating tags. (#18116)
Co-authored-by: wxiaoguang <[email protected]>
1 parent 72f9050 commit 8fa97a2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

services/release/release.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ func createTag(gitRepo *git.Repository, rel *models.Release, msg string) (bool,
7272
created = true
7373
rel.LowerTagName = strings.ToLower(rel.TagName)
7474

75+
commits := repository.NewPushCommits()
76+
commits.HeadCommit = repository.CommitToPushCommit(commit)
77+
commits.CompareURL = rel.Repo.ComposeCompareURL(git.EmptySHA, commit.ID.String())
78+
7579
notification.NotifyPushCommits(
7680
rel.Publisher, rel.Repo,
7781
&repository.PushUpdateOptions{
7882
RefFullName: git.TagPrefix + rel.TagName,
7983
OldCommitID: git.EmptySHA,
8084
NewCommitID: commit.ID.String(),
81-
}, repository.NewPushCommits())
85+
}, commits)
8286
notification.NotifyCreateRef(rel.Publisher, rel.Repo, "tag", git.TagPrefix+rel.TagName)
8387
rel.CreatedUnix = timeutil.TimeStampNow()
8488
}

services/repository/push.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,22 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
121121
delTags = append(delTags, tagName)
122122
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
123123
} else { // is new tag
124+
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
125+
if err != nil {
126+
return fmt.Errorf("gitRepo.GetCommit: %v", err)
127+
}
128+
129+
commits := repo_module.NewPushCommits()
130+
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
131+
commits.CompareURL = repo.ComposeCompareURL(git.EmptySHA, opts.NewCommitID)
132+
124133
notification.NotifyPushCommits(
125134
pusher, repo,
126135
&repo_module.PushUpdateOptions{
127136
RefFullName: git.TagPrefix + tagName,
128137
OldCommitID: git.EmptySHA,
129138
NewCommitID: opts.NewCommitID,
130-
}, repo_module.NewPushCommits())
139+
}, commits)
131140

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

0 commit comments

Comments
 (0)