aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-12-30 23:34:11 +0000
committertechknowlogick <techknowlogick@gitea.io>2019-12-30 18:34:11 -0500
commit0c07f1de5b8cf7b9f9f607aae76a53c99aeb2c04 (patch)
treed9dcb3161784f012ae80429aae8a9576894e0fd2 /modules
parentb983ff447387d40700ad8c0a56f90052878fec98 (diff)
downloadgitea-0c07f1de5b8cf7b9f9f607aae76a53c99aeb2c04.tar.gz
gitea-0c07f1de5b8cf7b9f9f607aae76a53c99aeb2c04.zip
Provide Default messages for merges (#9393)
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/repo_commit.go26
-rw-r--r--modules/setting/repository.go31
2 files changed, 48 insertions, 9 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go
index 5808c7600e..8762b63e2e 100644
--- a/modules/git/repo_commit.go
+++ b/modules/git/repo_commit.go
@@ -315,7 +315,28 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
// CommitsBetween returns a list that contains commits between [last, before).
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
- stdout, err := NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
+ var stdout []byte
+ var err error
+ if before == nil {
+ stdout, err = NewCommand("rev-list", before.ID.String()).RunInDirBytes(repo.Path)
+ } else {
+ stdout, err = NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
+ }
+ if err != nil {
+ return nil, err
+ }
+ return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
+}
+
+// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [last, before)
+func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) (*list.List, error) {
+ var stdout []byte
+ var err error
+ if before == nil {
+ stdout, err = NewCommand("rev-list", "--max-count", strconv.Itoa(limit), "--skip", strconv.Itoa(skip), last.ID.String()).RunInDirBytes(repo.Path)
+ } else {
+ stdout, err = NewCommand("rev-list", "--max-count", strconv.Itoa(limit), "--skip", strconv.Itoa(skip), before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
+ }
if err != nil {
return nil, err
}
@@ -328,6 +349,9 @@ func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, erro
if err != nil {
return nil, err
}
+ if before == "" {
+ return repo.CommitsBetween(lastCommit, nil)
+ }
beforeCommit, err := repo.GetCommit(before)
if err != nil {
return nil, err
diff --git a/modules/setting/repository.go b/modules/setting/repository.go
index 3e7393efb6..06797e891b 100644
--- a/modules/setting/repository.go
+++ b/modules/setting/repository.go
@@ -60,9 +60,14 @@ var (
// Pull request settings
PullRequest struct {
- WorkInProgressPrefixes []string
- CloseKeywords []string
- ReopenKeywords []string
+ WorkInProgressPrefixes []string
+ CloseKeywords []string
+ ReopenKeywords []string
+ DefaultMergeMessageCommitsLimit int
+ DefaultMergeMessageSize int
+ DefaultMergeMessageAllAuthors bool
+ DefaultMergeMessageMaxApprovers int
+ DefaultMergeMessageOfficialApproversOnly bool
} `ini:"repository.pull-request"`
// Issue Setting
@@ -127,15 +132,25 @@ var (
// Pull request settings
PullRequest: struct {
- WorkInProgressPrefixes []string
- CloseKeywords []string
- ReopenKeywords []string
+ WorkInProgressPrefixes []string
+ CloseKeywords []string
+ ReopenKeywords []string
+ DefaultMergeMessageCommitsLimit int
+ DefaultMergeMessageSize int
+ DefaultMergeMessageAllAuthors bool
+ DefaultMergeMessageMaxApprovers int
+ DefaultMergeMessageOfficialApproversOnly bool
}{
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
// Same as GitHub. See
// https://help.github.com/articles/closing-issues-via-commit-messages
- CloseKeywords: strings.Split("close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved", ","),
- ReopenKeywords: strings.Split("reopen,reopens,reopened", ","),
+ CloseKeywords: strings.Split("close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved", ","),
+ ReopenKeywords: strings.Split("reopen,reopens,reopened", ","),
+ DefaultMergeMessageCommitsLimit: 50,
+ DefaultMergeMessageSize: 5 * 1024,
+ DefaultMergeMessageAllAuthors: false,
+ DefaultMergeMessageMaxApprovers: 10,
+ DefaultMergeMessageOfficialApproversOnly: true,
},
// Issue settings