Skip to content

Commit de63ac0

Browse files
authored
Make PR message on pushes configurable (#10664)
* Make PR message on pushes configurable * Make fmt Signed-off-by: jolheiser <[email protected]>
1 parent b40428a commit de63ac0

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

custom/conf/app.ini.sample

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,9 @@ MAX_GIT_DIFF_FILES = 100
870870
; see more on http://git-scm.com/docs/git-gc/
871871
GC_ARGS =
872872
; If use git wire protocol version 2 when git version >= 2.18, default is true, set to false when you always want git wire protocol version 1
873-
EnableAutoGitWireProtocol = true
873+
ENABLE_AUTO_GIT_WIRE_PROTOCOL = true
874+
; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
875+
PULL_REQUEST_PUSH_MESSAGE = true
874876

875877
; Operation timeout in seconds
876878
[git.timeout]

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false`
541541
- `MAX_GIT_DIFF_FILES`: **100**: Max number of files shown in diff view.
542542
- `GC_ARGS`: **\<empty\>**: Arguments for command `git gc`, e.g. `--aggressive --auto`. See more on http://git-scm.com/docs/git-gc/
543543
- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: If use git wire protocol version 2 when git version >= 2.18, default is true, set to false when you always want git wire protocol version 1
544+
- `PULL_REQUEST_PUSH_MESSAGE`: **true**: Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
544545
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
545546
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
546547

modules/setting/git.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
VerbosePushDelay time.Duration
2626
GCArgs []string `ini:"GC_ARGS" delim:" "`
2727
EnableAutoGitWireProtocol bool
28+
PullRequestPushMessage bool
2829
Timeout struct {
2930
Default int
3031
Migrate int
@@ -42,6 +43,7 @@ var (
4243
VerbosePushDelay: 5 * time.Second,
4344
GCArgs: []string{},
4445
EnableAutoGitWireProtocol: true,
46+
PullRequestPushMessage: true,
4547
Timeout: struct {
4648
Default int
4749
Migrate int

routers/private/hook.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"code.gitea.io/gitea/modules/log"
2020
"code.gitea.io/gitea/modules/private"
2121
"code.gitea.io/gitea/modules/repofiles"
22+
"code.gitea.io/gitea/modules/setting"
2223
"code.gitea.io/gitea/modules/util"
2324
pull_service "code.gitea.io/gitea/services/pull"
2425
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -428,14 +429,14 @@ func HookPostReceive(ctx *macaron.Context, opts private.HookOptions) {
428429
branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch)
429430
}
430431
results = append(results, private.HookPostReceiveBranchResult{
431-
Message: true,
432+
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(),
432433
Create: true,
433434
Branch: branch,
434435
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)),
435436
})
436437
} else {
437438
results = append(results, private.HookPostReceiveBranchResult{
438-
Message: true,
439+
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(),
439440
Create: false,
440441
Branch: branch,
441442
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index),

0 commit comments

Comments
 (0)