aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunny Xiao2022-01-04 09:22:10 +0800
committerGitHub2022-01-04 02:22:10 +0100
commitb25a571bc979d1a7483f488be7e342299837637b (patch)
tree258fe504e3db334423d97795a7c530afc7a8b215
parentf9bbed028cd13ff039f6cde227f3da2920c44e5e (diff)
Set HeadCommit when creating tags. (#18116) (#18173)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
-rw-r--r--services/release/release.go6
-rw-r--r--services/repository/push.go11
2 files changed, 15 insertions, 2 deletions
diff --git a/services/release/release.go b/services/release/release.go
index 4a55f73a3..8ba739d8e 100644
--- a/services/release/release.go
+++ b/services/release/release.go
@@ -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()
}
diff --git a/services/repository/push.go b/services/repository/push.go
index dde621e1d..93131d063 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -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)