Skip to content

Commit

Permalink
Merge branch 'master' into webhook-list
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Dec 16, 2020
2 parents e004d15 + 53308de commit 127ea20
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
14 changes: 7 additions & 7 deletions services/pull/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models

// Only fetch diff if comment is review comment
if len(patch) == 0 && reviewID != 0 {
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
if err != nil {
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
}
if len(commitID) == 0 {
commitID, err = gitRepo.GetRefCommitID(pr.GetGitRefName())
if err != nil {
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
}
commitID = headCommitID
}

patchBuf := new(bytes.Buffer)
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, commitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, commitID, treePath, err)
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, headCommitID, treePath, err)
}
patch = git.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
}
Expand Down
9 changes: 9 additions & 0 deletions services/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ func DeleteReleaseByID(id int64, doer *models.User, delTag bool) error {
return fmt.Errorf("git tag -d: %v", err)
}

notification.NotifyPushCommits(
doer, repo,
&repository.PushUpdateOptions{
RefFullName: git.TagPrefix + rel.TagName,
OldCommitID: rel.Sha1,
NewCommitID: git.EmptySHA,
}, repository.NewPushCommits())
notification.NotifyDeleteRef(doer, repo, "tag", git.TagPrefix+rel.TagName)

if err := models.DeleteReleaseByID(id); err != nil {
return fmt.Errorf("DeleteReleaseByID: %v", err)
}
Expand Down
18 changes: 17 additions & 1 deletion services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
return fmt.Errorf("Old and new revisions are both %s", git.EmptySHA)
}
var commits = &repo_module.PushCommits{}
if opts.IsTag() { // If is tag reference {
if opts.IsTag() { // If is tag reference
if pusher == nil || pusher.ID != opts.PusherID {
var err error
if pusher, err = models.GetUserByID(opts.PusherID); err != nil {
Expand All @@ -105,9 +105,25 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
tagName := opts.TagName()
if opts.IsDelRef() {
notification.NotifyPushCommits(
pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: opts.OldCommitID,
NewCommitID: git.EmptySHA,
}, repo_module.NewPushCommits())

delTags = append(delTags, tagName)
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
} else { // is new tag
notification.NotifyPushCommits(
pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: git.EmptySHA,
NewCommitID: opts.NewCommitID,
}, repo_module.NewPushCommits())

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

0 comments on commit 127ea20

Please sign in to comment.