summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2019-08-11 22:31:18 +0200
committerLauris BH <lauris@nix.lv>2019-08-11 23:31:18 +0300
commite9bb75d8d18ba88dc26e4c4af6dc66812a9b8fb6 (patch)
treea4940d4ff3c8c16015a13be3c8540ec63565890b /modules
parent8bfeb85f93ccd41289f901977243258e1b69f4d6 (diff)
downloadgitea-e9bb75d8d18ba88dc26e4c4af6dc66812a9b8fb6.tar.gz
gitea-e9bb75d8d18ba88dc26e4c4af6dc66812a9b8fb6.zip
Fix duplicate call of webhook (#7821)
Diffstat (limited to 'modules')
-rw-r--r--modules/pull/merge.go33
-rw-r--r--modules/repofiles/delete.go26
-rw-r--r--modules/repofiles/update.go26
-rw-r--r--modules/repofiles/upload.go27
4 files changed, 0 insertions, 112 deletions
diff --git a/modules/pull/merge.go b/modules/pull/merge.go
index ed2fe48379..cf2fb7fc4f 100644
--- a/modules/pull/merge.go
+++ b/modules/pull/merge.go
@@ -292,39 +292,6 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
go models.HookQueue.Add(pr.Issue.Repo.ID)
}
- l, err := baseGitRepo.CommitsBetweenIDs(pr.MergedCommitID, pr.MergeBase)
- if err != nil {
- log.Error("CommitsBetweenIDs: %v", err)
- return nil
- }
-
- // It is possible that head branch is not fully sync with base branch for merge commits,
- // so we need to get latest head commit and append merge commit manually
- // to avoid strange diff commits produced.
- mergeCommit, err := baseGitRepo.GetBranchCommit(pr.BaseBranch)
- if err != nil {
- log.Error("GetBranchCommit: %v", err)
- return nil
- }
- if mergeStyle == models.MergeStyleMerge {
- l.PushFront(mergeCommit)
- }
-
- p := &api.PushPayload{
- Ref: git.BranchPrefix + pr.BaseBranch,
- Before: pr.MergeBase,
- After: mergeCommit.ID.String(),
- CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
- Commits: models.ListToPushCommits(l).ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()),
- Repo: pr.BaseRepo.APIFormat(mode),
- Pusher: pr.HeadRepo.MustOwner().APIFormat(),
- Sender: doer.APIFormat(),
- }
- if err = models.PrepareWebhooks(pr.BaseRepo, models.HookEventPush, p); err != nil {
- log.Error("PrepareWebhooks: %v", err)
- } else {
- go models.HookQueue.Add(pr.BaseRepo.ID)
- }
return nil
}
diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go
index a8ab277b28..2210faae6b 100644
--- a/modules/repofiles/delete.go
+++ b/modules/repofiles/delete.go
@@ -178,32 +178,6 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo
return nil, err
}
- // Simulate push event.
- oldCommitID := opts.LastCommitID
- if opts.NewBranch != opts.OldBranch {
- oldCommitID = git.EmptySHA
- }
-
- if err = repo.GetOwner(); err != nil {
- return nil, fmt.Errorf("GetOwner: %v", err)
- }
- err = PushUpdate(
- repo,
- opts.NewBranch,
- models.PushUpdateOptions{
- PusherID: doer.ID,
- PusherName: doer.Name,
- RepoUserName: repo.Owner.Name,
- RepoName: repo.Name,
- RefFullName: git.BranchPrefix + opts.NewBranch,
- OldCommitID: oldCommitID,
- NewCommitID: commitHash,
- },
- )
- if err != nil {
- return nil, fmt.Errorf("PushUpdate: %v", err)
- }
-
commit, err = t.GetCommit(commitHash)
if err != nil {
return nil, err
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index 26b5113f15..62e2afbc96 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -396,32 +396,6 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
return nil, err
}
- // Simulate push event.
- oldCommitID := opts.LastCommitID
- if opts.NewBranch != opts.OldBranch || oldCommitID == "" {
- oldCommitID = git.EmptySHA
- }
-
- if err = repo.GetOwner(); err != nil {
- return nil, fmt.Errorf("GetOwner: %v", err)
- }
- err = PushUpdate(
- repo,
- opts.NewBranch,
- models.PushUpdateOptions{
- PusherID: doer.ID,
- PusherName: doer.Name,
- RepoUserName: repo.Owner.Name,
- RepoName: repo.Name,
- RefFullName: git.BranchPrefix + opts.NewBranch,
- OldCommitID: oldCommitID,
- NewCommitID: commitHash,
- },
- )
- if err != nil {
- return nil, fmt.Errorf("PushUpdate: %v", err)
- }
-
commit, err = t.GetCommit(commitHash)
if err != nil {
return nil, err
diff --git a/modules/repofiles/upload.go b/modules/repofiles/upload.go
index 2da101c64d..f2ffec7ebc 100644
--- a/modules/repofiles/upload.go
+++ b/modules/repofiles/upload.go
@@ -11,7 +11,6 @@ import (
"strings"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/setting"
)
@@ -177,31 +176,5 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep
return err
}
- // Simulate push event.
- oldCommitID := opts.LastCommitID
- if opts.NewBranch != opts.OldBranch {
- oldCommitID = git.EmptySHA
- }
-
- if err = repo.GetOwner(); err != nil {
- return fmt.Errorf("GetOwner: %v", err)
- }
- err = PushUpdate(
- repo,
- opts.NewBranch,
- models.PushUpdateOptions{
- PusherID: doer.ID,
- PusherName: doer.Name,
- RepoUserName: repo.Owner.Name,
- RepoName: repo.Name,
- RefFullName: git.BranchPrefix + opts.NewBranch,
- OldCommitID: oldCommitID,
- NewCommitID: commitHash,
- },
- )
- if err != nil {
- return fmt.Errorf("PushUpdate: %v", err)
- }
-
return models.DeleteUploads(uploads...)
}