Skip to content

Commit 127ea20

Browse files
authored
Merge branch 'master' into webhook-list
2 parents e004d15 + 53308de commit 127ea20

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

services/pull/review.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models
167167

168168
// Only fetch diff if comment is review comment
169169
if len(patch) == 0 && reviewID != 0 {
170+
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
171+
if err != nil {
172+
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
173+
}
170174
if len(commitID) == 0 {
171-
commitID, err = gitRepo.GetRefCommitID(pr.GetGitRefName())
172-
if err != nil {
173-
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
174-
}
175+
commitID = headCommitID
175176
}
176-
177177
patchBuf := new(bytes.Buffer)
178-
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, commitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
179-
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, commitID, treePath, err)
178+
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
179+
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, headCommitID, treePath, err)
180180
}
181181
patch = git.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
182182
}

services/release/release.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ func DeleteReleaseByID(id int64, doer *models.User, delTag bool) error {
152152
return fmt.Errorf("git tag -d: %v", err)
153153
}
154154

155+
notification.NotifyPushCommits(
156+
doer, repo,
157+
&repository.PushUpdateOptions{
158+
RefFullName: git.TagPrefix + rel.TagName,
159+
OldCommitID: rel.Sha1,
160+
NewCommitID: git.EmptySHA,
161+
}, repository.NewPushCommits())
162+
notification.NotifyDeleteRef(doer, repo, "tag", git.TagPrefix+rel.TagName)
163+
155164
if err := models.DeleteReleaseByID(id); err != nil {
156165
return fmt.Errorf("DeleteReleaseByID: %v", err)
157166
}

services/repository/push.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
9696
return fmt.Errorf("Old and new revisions are both %s", git.EmptySHA)
9797
}
9898
var commits = &repo_module.PushCommits{}
99-
if opts.IsTag() { // If is tag reference {
99+
if opts.IsTag() { // If is tag reference
100100
if pusher == nil || pusher.ID != opts.PusherID {
101101
var err error
102102
if pusher, err = models.GetUserByID(opts.PusherID); err != nil {
@@ -105,9 +105,25 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
105105
}
106106
tagName := opts.TagName()
107107
if opts.IsDelRef() {
108+
notification.NotifyPushCommits(
109+
pusher, repo,
110+
&repo_module.PushUpdateOptions{
111+
RefFullName: git.TagPrefix + tagName,
112+
OldCommitID: opts.OldCommitID,
113+
NewCommitID: git.EmptySHA,
114+
}, repo_module.NewPushCommits())
115+
108116
delTags = append(delTags, tagName)
109117
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
110118
} else { // is new tag
119+
notification.NotifyPushCommits(
120+
pusher, repo,
121+
&repo_module.PushUpdateOptions{
122+
RefFullName: git.TagPrefix + tagName,
123+
OldCommitID: git.EmptySHA,
124+
NewCommitID: opts.NewCommitID,
125+
}, repo_module.NewPushCommits())
126+
111127
addTags = append(addTags, tagName)
112128
notification.NotifyCreateRef(pusher, repo, "tag", opts.RefFullName)
113129
}

0 commit comments

Comments
 (0)