summaryrefslogtreecommitdiffstats
path: root/routers/private
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-02-03 04:27:34 +0800
committerGitHub <noreply@github.com>2020-02-02 15:27:34 -0500
commitbf1970d0bd5137a2e8102e117d56b27a13fb1627 (patch)
treeb4fff5ada06d6bb2a055b058e3918efcbb622288 /routers/private
parent70aa629ae7b1a21a4de099dfadc7845e80aeeb25 (diff)
downloadgitea-bf1970d0bd5137a2e8102e117d56b27a13fb1627.tar.gz
gitea-bf1970d0bd5137a2e8102e117d56b27a13fb1627.zip
Improve push update options (#10105)
* Improve push update options * fix test * More refactor and fix lint * fix lint * Fix lint Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/private')
-rw-r--r--routers/private/hook.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/routers/private/hook.go b/routers/private/hook.go
index 7044fdac22..44e82ebe6c 100644
--- a/routers/private/hook.go
+++ b/routers/private/hook.go
@@ -304,12 +304,6 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
for i := range opts.OldCommitIDs {
refFullName := opts.RefFullNames[i]
- branch := opts.RefFullNames[i]
- if strings.HasPrefix(branch, git.BranchPrefix) {
- branch = strings.TrimPrefix(branch, git.BranchPrefix)
- } else {
- branch = strings.TrimPrefix(branch, git.TagPrefix)
- }
// Only trigger activity updates for changes to branches or
// tags. Updates to other refs (eg, refs/notes, refs/changes,
@@ -336,14 +330,13 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
RefFullName: refFullName,
OldCommitID: opts.OldCommitIDs[i],
NewCommitID: opts.NewCommitIDs[i],
- Branch: branch,
PusherID: opts.UserID,
PusherName: opts.UserName,
RepoUserName: ownerName,
RepoName: repoName,
}
updates = append(updates, &option)
- if repo.IsEmpty && branch == "master" && strings.HasPrefix(refFullName, git.BranchPrefix) {
+ if repo.IsEmpty && option.IsBranch() && option.BranchName() == "master" {
// put the master branch first
copy(updates[1:], updates)
updates[0] = &option
@@ -355,7 +348,7 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
if err := repofiles.PushUpdates(repo, updates); err != nil {
log.Error("Failed to Update: %s/%s Total Updates: %d", ownerName, repoName, len(updates))
for i, update := range updates {
- log.Error("Failed to Update: %s/%s Update: %d/%d: Branch: %s", ownerName, repoName, i, len(updates), update.Branch)
+ log.Error("Failed to Update: %s/%s Update: %d/%d: Branch: %s", ownerName, repoName, i, len(updates), update.BranchName())
}
log.Error("Failed to Update: %s/%s Error: %v", ownerName, repoName, err)