-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable merging a WIP Pull request #4529
Changes from 9 commits
b51d021
4e04e18
2950078
864f795
195b413
eaadddd
f150a20
45732db
f146aea
404541a
af9f432
6f766a2
7dbb842
cdecb10
a2bf0bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
date: "2018-06-01T19:00:00+02:00" | ||
title: "Usage: Pull Request" | ||
slug: "pull-request" | ||
weight: 13 | ||
toc: true | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "usage" | ||
name: "Pull Request" | ||
weight: 13 | ||
identifier: "pull-request" | ||
--- | ||
|
||
# Pull Request | ||
|
||
## "Work In Progress" pull requests | ||
|
||
Marking a pull request as being a work in progress will prevent that pull request from being accidentally merged. To mark a pull request as being a work in progress, you must prefix its title by `WIP:` or `[WIP]` (case insensitive). Those values are configurable in your `app.ini` file : | ||
|
||
``` | ||
[repository.pull-request] | ||
WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP] | ||
``` | ||
|
||
The first value of the list will be used in helpers. | ||
|
||
## Pull Request Templates | ||
|
||
You can find more information about pull request templates into the dedicated page : [Issue and Pull Request templates](../issue-pull-request-templates) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be in the dedicated page not into the dedicated page |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,12 @@ | |
package integrations | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
"code.gitea.io/gitea/modules/auth" | ||
api "code.gitea.io/sdk/gitea" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -28,3 +30,20 @@ func TestAPIViewPulls(t *testing.T) { | |
expectedLen := models.GetCount(t, &models.Issue{RepoID: repo.ID}, models.Cond("is_pull = ?", true)) | ||
assert.Len(t, pulls, expectedLen) | ||
} | ||
|
||
// TestAPIMergePullWIP ensures that we can't merge a WIP pull request | ||
func TestAPIMergePullWIP(t *testing.T) { | ||
prepareTestEnv(t) | ||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) | ||
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User) | ||
pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{Status: models.PullRequestStatusMergeable, HasMerged: false}).(*models.PullRequest) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this PR really have WIP prefix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow this is a mistake i'm sorry :/ |
||
pr.LoadIssue() | ||
|
||
session := loginUser(t, owner.Name) | ||
req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge", owner.Name, repo.Name, pr.Index), &auth.MergePullRequestForm{ | ||
MergeMessageField: pr.Issue.Title, | ||
Do: string(models.MergeStyleMerge), | ||
}) | ||
|
||
session.MakeRequest(t, req, http.StatusMethodNotAllowed) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -829,13 +829,16 @@ pulls.tab_files = Files Changed | |
pulls.reopen_to_merge = Please reopen this pull request to perform a merge. | ||
pulls.merged = Merged | ||
pulls.has_merged = The pull request has been merged. | ||
pulls.title_wip_desc = '<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There would be needed backtick (`) quotes |
||
pulls.cannot_merge_work_in_progress = "This pull request is marked as a work in progress. Remove the <strong>%s</strong> prefix from the title when it's ready" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for quoting with |
||
pulls.data_broken = This pull request is broken due to missing fork information. | ||
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments." | ||
pulls.can_auto_merge_desc = This pull request can be merged automatically. | ||
pulls.cannot_auto_merge_desc = This pull request cannot be merged automatically due to conflicts. | ||
pulls.cannot_auto_merge_helper = Merge manually to resolve the conflicts. | ||
pulls.no_merge_desc = This pull request cannot be merged because all repository merge options are disabled. | ||
pulls.no_merge_helper = Enable merge options in the repository settings or merge the pull request manually. | ||
pulls.no_merge_wip = "This pull request can not be merged because it is marked as being a work in progress." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for quoting with |
||
pulls.merge_pull_request = Merge Pull Request | ||
pulls.rebase_merge_pull_request = Rebase and Merge | ||
pulls.squash_merge_pull_request = Squash and Merge | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1557,6 +1557,27 @@ function u2fRegisterRequest() { | |
}); | ||
} | ||
|
||
function initWipTitle() { | ||
$(".title_wip_desc > a").click(function (e) { | ||
e.preventDefault(); | ||
|
||
var $issueTitle = $("#issue_title"); | ||
var value = $issueTitle.val().trim().toUpperCase(); | ||
|
||
var addPrefix = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need for this variable. Can be changed so: for (var i in wipPrefixes) {
if (value.startsWith(wipPrefixes[i].toUpperCase())) {
return;
}
}
$issueTitle.val(wipPrefixes[0] + " " + $issueTitle.val()); |
||
for (var i in wipPrefixes) { | ||
if (value.startsWith(wipPrefixes[i].toUpperCase())) { | ||
addPrefix = false; | ||
break; | ||
} | ||
} | ||
|
||
if (addPrefix) { | ||
$issueTitle.val(wipPrefixes[0] + " " + $issueTitle.val()); | ||
} | ||
}); | ||
} | ||
|
||
$(document).ready(function () { | ||
csrf = $('meta[name=_csrf]').attr("content"); | ||
suburl = $('meta[name=_suburl]').attr("content"); | ||
|
@@ -1771,6 +1792,7 @@ $(document).ready(function () { | |
initU2FAuth(); | ||
initU2FRegister(); | ||
initIssueList(); | ||
initWipTitle(); | ||
|
||
// Repo clone url. | ||
if ($('#repo-clone-url').length > 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it’s title
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm pretty sure that
its
is correct, http://grammarist.com/spelling/its-its/There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... Thanks for the link