Commit d5d2b570 authored by Ruben Davila's avatar Ruben Davila

Merge branch 'master' into ce-to-ee

parents 9e397aac a294fe2f
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.12.0 (Unreleased) v 8.12.0 (Unreleased)
v 8.11.5
- API: Restore backward-compatibility for POST /projects/:id/members when membership is locked
v 8.11.4
- No EE-specific changes
v 8.11.3 v 8.11.3
- [ES] Add logging to indexer - [ES] Add logging to indexer
- Fix missing EE-specific service parameters for Jenkins CI - Fix missing EE-specific service parameters for Jenkins CI
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
%strong Only allow merge requests to be merged if the build succeeds %strong Only allow merge requests to be merged if the build succeeds
.help-block .help-block
Builds need to be configured to enable this feature. Builds need to be configured to enable this feature.
= link_to icon('question-circle'), help_page_path('workflow/merge_requests', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds') = link_to icon('question-circle'), help_page_path('user/project/merge_requests/merge_when_build_succeeds', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds')
:javascript :javascript
new UsersSelect(); new UsersSelect();
...@@ -47,8 +47,9 @@ ...@@ -47,8 +47,9 @@
Note that pushing to GitLab requires write access to this repository. Note that pushing to GitLab requires write access to this repository.
%p %p
%strong Tip: %strong Tip:
You can also checkout merge requests locally by = succeed '.' do
%a{href: 'https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/workflow/merge_requests.md#checkout-merge-requests-locally', target: '_blank'} following these guidelines You can also checkout merge requests locally by
= link_to 'following these guidelines', help_page_path('user/project/merge_requests.md', anchor: "checkout-merge-requests-locally"), target: '_blank'
:javascript :javascript
$(function(){ $(function(){
......
...@@ -23,9 +23,9 @@ Create merge requests and review code. ...@@ -23,9 +23,9 @@ Create merge requests and review code.
- [Fork a project and contribute to it](../workflow/forking_workflow.md) - [Fork a project and contribute to it](../workflow/forking_workflow.md)
- [Create a new merge request](../gitlab-basics/add-merge-request.md) - [Create a new merge request](../gitlab-basics/add-merge-request.md)
- [Automatically close issues from merge requests](../customization/issue_closing.md) - [Automatically close issues from merge requests](../customization/issue_closing.md)
- [Automatically merge when your builds succeed](../workflow/merge_when_build_succeeds.md) - [Automatically merge when your builds succeed](../user/project/merge_requests/merge_when_build_succeeds.md)
- [Revert any commit](../workflow/revert_changes.md) - [Revert any commit](../user/project/merge_requests/revert_changes.md)
- [Cherry-pick any commit](../workflow/cherry_pick_changes.md) - [Cherry-pick any commit](../user/project/merge_requests/cherry_pick_changes.md)
## Test and Deploy ## Test and Deploy
......
# Merge Requests
Merge requests allow you to exchange changes you made to source code and
collaborate with other people on the same project.
## Authorization for merge requests
There are two main ways to have a merge request flow with GitLab:
1. Working with [protected branches][] in a single repository
1. Working with forks of an authoritative project
[Learn more about the authorization for merge requests.](merge_requests/authorization_for_merge_requests.md)
## Cherry-pick changes
Cherry-pick any commit in the UI by simply clicking the **Cherry-pick** button
in a merged merge requests or a commit.
[Learn more about cherry-picking changes.](merge_requests/cherry_pick_changes.md)
## Merge when build succeeds
When reviewing a merge request that looks ready to merge but still has one or
more CI builds running, you can set it to be merged automatically when all
builds succeed. This way, you don't have to wait for the builds to finish and
remember to merge the request manually.
[Learn more about merging when build succeeds.](merge_requests/merge_when_build_succeeds.md)
## Resolve discussion comments in merge requests reviews
Keep track of the progress during a code review with resolving comments.
Resolving comments prevents you from forgetting to address feedback and lets
you hide discussions that are no longer relevant.
[Read more about resolving discussion comments in merge requests reviews.](merge_requests/merge_request_discussion_resolution.md)
## Resolve conflicts
When a merge request has conflicts, GitLab may provide the option to resolve
those conflicts in the GitLab UI.
[Learn more about resolving merge conflicts in the UI.](merge_requests/resolve_conflicts.md)
## Revert changes
GitLab implements Git's powerful feature to revert any commit with introducing
a **Revert** button in merge requests and commit details.
[Learn more about reverting changes in the UI](merge_requests/revert_changes.md)
## Merge requests versions
Every time you push to a branch that is tied to a merge request, a new version
of merge request diff is created. When you visit a merge request that contains
more than one pushes, you can select and compare the versions of those merge
request diffs.
[Read more about the merge requests versions.](merge_requests/versions.md)
## Work In Progress merge requests
To prevent merge requests from accidentally being accepted before they're
completely ready, GitLab blocks the "Accept" button for merge requests that
have been marked as a **Work In Progress**.
[Learn more about settings a merge request as "Work In Progress".](merge_requests/work_in_progress_merge_requests.md)
## Merge request approvals
If you want to make sure every merge request is approved by one or more people,
you can enforce this workflow by using merge request approvals. Merge request
approvals allow you to set the number of necessary approvals and predefine a
list of approvers that will need to approve every merge request in a project.
[Read more about merge request approvals.](merge_requests/merge_request_approvals.md)
## Ignore whitespace changes in Merge Request diff view
If you click the **Hide whitespace changes** button, you can see the diff
without whitespace changes (if there are any). This is also working when on a
specific commit page.
![MR diff](merge_requests/img/merge_request_diff.png)
>**Tip:**
You can append `?w=1` while on the diffs page of a merge request to ignore any
whitespace changes.
## Tips
Here are some tips that will help you be more efficient with merge requests in
the command line.
> **Note:**
This section might move in its own document in the future.
### Checkout merge requests locally
A merge request contains all the history from a repository, plus the additional
commits added to the branch associated with the merge request. Here's a few
tricks to checkout a merge request locally.
#### Checkout locally by adding a git alias
Add the following alias to your `~/.gitconfig`:
```
[alias]
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
```
Now you can check out a particular merge request from any repository and any
remote. For example, to check out the merge request with ID 5 as shown in GitLab
from the `upstream` remote, do:
```
git mr upstream 5
```
This will fetch the merge request into a local `mr-upstream-5` branch and check
it out.
#### Checkout locally by modifying `.git/config` for a given repository
Locate the section for your GitLab remote in the `.git/config` file. It looks
like this:
```
[remote "origin"]
url = https://gitlab.com/gitlab-org/gitlab-ce.git
fetch = +refs/heads/*:refs/remotes/origin/*
```
You can open the file with:
```
git config -e
```
Now add the following line to the above section:
```
fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
```
In the end, it should look like this:
```
[remote "origin"]
url = https://gitlab.com/gitlab-org/gitlab-ce.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
```
Now you can fetch all the merge requests:
```
git fetch origin
...
From https://gitlab.com/gitlab-org/gitlab-ce.git
* [new ref] refs/merge-requests/1/head -> origin/merge-requests/1
* [new ref] refs/merge-requests/2/head -> origin/merge-requests/2
...
```
And to check out a particular merge request:
```
git checkout origin/merge-requests/1
```
[protected branches]: protected_branches.md
# Authorization for Merge requests
There are two main ways to have a merge request flow with GitLab:
1. Working with [protected branches] in a single repository.
1. Working with forks of an authoritative project.
## Protected branch flow
With the protected branch flow everybody works within the same GitLab project.
The project maintainers get Master access and the regular developers get
Developer access.
The maintainers mark the authoritative branches as 'Protected'.
The developers push feature branches to the project and create merge requests
to have their feature branches reviewed and merged into one of the protected
branches.
By default, only users with Master access can merge changes into a protected
branch.
**Advantages**
- Fewer projects means less clutter.
- Developers need to consider only one remote repository.
**Disadvantages**
- Manual setup of protected branch required for each new project
## Forking workflow
With the forking workflow the maintainers get Master access and the regular
developers get Reporter access to the authoritative repository, which prohibits
them from pushing any changes to it.
Developers create forks of the authoritative project and push their feature
branches to their own forks.
To get their changes into master they need to create a merge request across
forks.
**Advantages**
- In an appropriately configured GitLab group, new projects automatically get
the required access restrictions for regular developers: fewer manual steps
to configure authorization for new projects.
**Disadvantages**
- The project need to keep their forks up to date, which requires more advanced
Git skills (managing multiple remotes).
[protected branches]: ../protected_branches.md
# Cherry-pick changes
> [Introduced][ce-3514] in GitLab 8.7.
---
GitLab implements Git's powerful feature to [cherry-pick any commit][git-cherry-pick]
with introducing a **Cherry-pick** button in Merge Requests and commit details.
## Cherry-picking a Merge Request
After the Merge Request has been merged, a **Cherry-pick** button will be available
to cherry-pick the changes introduced by that Merge Request:
![Cherry-pick Merge Request](img/cherry_pick_changes_mr.png)
---
You can cherry-pick the changes directly into the selected branch or you can opt to
create a new Merge Request with the cherry-pick changes:
![Cherry-pick Merge Request modal](img/cherry_pick_changes_mr_modal.png)
## Cherry-picking a Commit
You can cherry-pick a Commit from the Commit details page:
![Cherry-pick commit](img/cherry_pick_changes_commit.png)
---
Similar to cherry-picking a Merge Request, you can opt to cherry-pick the changes
directly into the target branch or create a new Merge Request to cherry-pick the
changes:
![Cherry-pick commit modal](img/cherry_pick_changes_commit_modal.png)
---
Please note that when cherry-picking merge commits, the mainline will always be the
first parent. If you want to use a different mainline then you need to do that
from the command line.
Here is a quick example to cherry-pick a merge commit using the second parent as the
mainline:
```bash
git cherry-pick -m 2 7a39eb0
```
[ce-3514]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3514 "Cherry-pick button Merge Request"
[git-cherry-pick]: https://git-scm.com/docs/git-cherry-pick "Git cherry-pick documentation"
# Fast-forward merge
GitLab Enterprise Edition offers a way to accept merge requests without creating
merge commits. If you prefer a linear git history, this might be a good feature
for you.
You can configure this on a per-project basis by navigating to the project
settings page and selecting the **Only fast-forward merging** checkbox.
![Fast forward merge in project settings](img/ff_merge.png)
Now, when you visit the merge request page, you will be able to **accept it only
if a fast-forward merge is possible**.
If the target branch is ahead of the source branch, you need to rebase the
source branch before you will be able to do a fast-forward merge.
For simple rebase operations, you can use the
[rebase before merge](rebase_before_merge.md) feature.
# Merge request approvals
> Introduced in GitLab Enterprise Edition 7.13.
If you want to make sure every merge request is approved by one or more
people, you can enforce this workflow by using merge request approvals.
Merge request approvals allow you to set the number of necessary approvals
and predefine a list of approvers that will need to approve every
merge request in a project.
## Configuring Approvals
You can configure the approvals in the project settings, under merge requests.
To enable it, set **Approvals required** to 1 or higher and search for the
users you want to be approvers.
![Merge Request Approvals in Project Settings](img/approvals_settings.png)
### Approvals Required
This sets the amount of approvals required before being able to merge a merge request.
At 0, this disables the feature. Any value above 0 requires that amount of different
users to approve the merge request.
The number of approvers can be higher than the required approvals.
### Reset approvals on push
With this setting turned on, approvals are reset when a new push
is done to the merge request branch.
Turn **Reset approvals on push** off if you want approvals to persist,
independent of changes to the merge request.
Approvals do not get reset when rebasing a merge request from the UI.
If one of the approvers pushes a commit to the branch that is tied to the
merge request, they automatically get excluded from the approvers list.
### Approvers
At the approvers area you can define the default set of users that need to
approve a merge request.
Depending on the number of required approvals and the number of approvers set,
there are different cases:
- If there are more approvers than required approvals, any subset of these users
can approve the merge request.
- If there are less approvers than required approvals, all the set approvers plus
any other user(s) need to approve the merge request before being able to merge it.
- If the approvers are equal to the amount of required approvals, all the
approvers are required to approve the merge request.
Note that approvers and the number of required approvals can be changed while
creating or editing a merge request.
When someone is marked as a required approver for a merge request, an email is
sent to them and a todo is added to their list of todos.
## Using approvals
After configuring approvals, you will be able to change the default set of
approvers and the amount of required approvals before creating the merge request.
The amount of required approvals, if changed, must be greater than the default
set at the project level. This ensures that you're not forced to adjust settings
when someone is unavailable for approval, yet the process is still enforced.
If the approvers are changed via the project's settings after a merge request
is created, the merge request retains the previous approvers, but you can always
change them by editing the merge request.
The author of a merge request cannot be set as an approver for that merge
request.
To approve a merge request, simply press the **Approve merge request** button.
![Merge request approval](img/approvals_mr.png)
Once you approve, the button will disappear and the number of approvers
will be decreased by one.
![Merge request approval](img/approvals_mr_approved.png)
# Merge When Build Succeeds
When reviewing a merge request that looks ready to merge but still has one or
more CI builds running, you can set it to be merged automatically when all
builds succeed. This way, you don't have to wait for the builds to finish and
remember to merge the request manually.
![Enable](img/merge_when_build_succeeds_enable.png)
When you hit the "Merge When Build Succeeds" button, the status of the merge
request will be updated to represent the impending merge. If you cannot wait
for the build to succeed and want to merge immediately, this option is available
in the dropdown menu on the right of the main button.
Both team developers and the author of the merge request have the option to
cancel the automatic merge if they find a reason why it shouldn't be merged
after all.
![Status](img/merge_when_build_succeeds_status.png)
When the build succeeds, the merge request will automatically be merged. When
the build fails, the author gets a chance to retry any failed builds, or to
push new commits to fix the failure.
When the builds are retried and succeed on the second try, the merge request
will automatically be merged after all. When the merge request is updated with
new commits, the automatic merge is automatically canceled to allow the new
changes to be reviewed.
## Only allow merge requests to be merged if the build succeeds
> **Note:**
You need to have builds configured to enable this feature.
You can prevent merge requests from being merged if their build did not succeed.
Navigate to your project's settings page, select the
**Only allow merge requests to be merged if the build succeeds** check box and
hit **Save** for the changes to take effect.
![Only allow merge if build succeeds settings](img/merge_when_build_succeeds_only_if_succeeds_settings.png)
From now on, every time the build fails you will not be able to merge the merge
request from the UI, until you make the build pass.
![Only allow merge if build succeeds msg](img/merge_when_build_succeeds_only_if_succeeds_msg.png)
# Reverting changes
> [Introduced][ce-1990] in GitLab 8.5.
---
GitLab implements Git's powerful feature to [revert any commit][git-revert]
with introducing a **Revert** button in Merge Requests and commit details.
## Reverting a Merge Request
_**Note:** The **Revert** button will only be available for Merge Requests
created since GitLab 8.5. However, you can still revert a Merge Request
by reverting the merge commit from the list of Commits page._
After the Merge Request has been merged, a **Revert** button will be available
to revert the changes introduced by that Merge Request:
![Revert Merge Request](img/revert_changes_mr.png)
---
You can revert the changes directly into the selected branch or you can opt to
create a new Merge Request with the revert changes:
![Revert Merge Request modal](img/revert_changes_mr_modal.png)
---
After the Merge Request has been reverted, the **Revert** button will not be
available anymore.
## Reverting a Commit
You can revert a Commit from the Commit details page:
![Revert commit](img/revert_changes_commit.png)
---
Similar to reverting a Merge Request, you can opt to revert the changes
directly into the target branch or create a new Merge Request to revert the
changes:
![Revert commit modal](img/revert_changes_commit_modal.png)
---
After the Commit has been reverted, the **Revert** button will not be available
anymore.
Please note that when reverting merge commits, the mainline will always be the
first parent. If you want to use a different mainline then you need to do that
from the command line.
Here is a quick example to revert a merge commit using the second parent as the
mainline:
```bash
git revert -m 2 7a39eb0
```
[ce-1990]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1990 "Revert button Merge Request"
[git-revert]: https://git-scm.com/docs/git-revert "Git revert documentation"
# Merge requests versions
> Will be [introduced][ce-5467] in GitLab 8.12.
Every time you push to a branch that is tied to a merge request, a new version
of merge request diff is created. When you visit a merge request that contains
more than one pushes, you can select and compare the versions of those merge
request diffs.
By default, the latest version of changes is shown. However, you
can select an older one from version dropdown.
![Merge Request Versions](img/versions.png)
---
>**Note:**
Merge request versions are based on push not on commit. So, if you pushed 5
commits in a single push, it will be a single option in the dropdown. If you
pushed 5 times, that will count for 5 options.
[ce-5467]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5467
# "Work In Progress" Merge Requests
To prevent merge requests from accidentally being accepted before they're
completely ready, GitLab blocks the "Accept" button for merge requests that
have been marked a **Work In Progress**.
![Blocked Accept Button](img/wip_blocked_accept_button.png)
To mark a merge request a Work In Progress, simply start its title with `[WIP]`
or `WIP:`.
![Mark as WIP](img/wip_mark_as_wip.png)
To allow a Work In Progress merge request to be accepted again when it's ready,
simply remove the `WIP` prefix.
![Unark as WIP](img/wip_unmark_as_wip.png)
# Workflow # Workflow
- [Authorization for merge requests](authorization_for_merge_requests.md)
- [Change your time zone](timezone.md) - [Change your time zone](timezone.md)
- [Description templates](../user/project/description_templates.md) - [Description templates](../user/project/description_templates.md)
- [Feature branch workflow](workflow.md) - [Feature branch workflow](workflow.md)
...@@ -14,13 +13,10 @@ ...@@ -14,13 +13,10 @@
- [Labels](../user/project/labels.md) - [Labels](../user/project/labels.md)
- [Issue weight](issue_weight.md) - [Issue weight](issue_weight.md)
- [Manage large binaries with git annex](git_annex.md) - [Manage large binaries with git annex](git_annex.md)
- [Merge Request Approvals](merge_request_approvals.md)
- [Notification emails](notifications.md) - [Notification emails](notifications.md)
- [Project Features](project_features.md) - [Project Features](project_features.md)
- [Project forking workflow](forking_workflow.md) - [Project forking workflow](forking_workflow.md)
- [Project users](add-user/add-user.md) - [Project users](add-user/add-user.md)
- [Fast-forward merge](ff_merge.md)
- [Rebase before merge](rebase_before_merge.md)
- [Protected branches](../user/project/protected_branches.md) - [Protected branches](../user/project/protected_branches.md)
- [Slash commands](../user/project/slash_commands.md) - [Slash commands](../user/project/slash_commands.md)
- [Sharing a project with a group](share_with_group.md) - [Sharing a project with a group](share_with_group.md)
...@@ -29,12 +25,17 @@ ...@@ -29,12 +25,17 @@
- [Web Editor](../user/project/repository/web_editor.md) - [Web Editor](../user/project/repository/web_editor.md)
- [Releases](releases.md) - [Releases](releases.md)
- [Milestones](milestones.md) - [Milestones](milestones.md)
- [Merge Requests](merge_requests.md) - [Merge Requests](../user/project/merge_requests.md)
- [Revert changes](revert_changes.md) - [Authorization for merge requests](../user/project/merge_requests/authorization_for_merge_requests.md)
- [Cherry-pick changes](cherry_pick_changes.md) - [Cherry-pick changes](../user/project/merge_requests/cherry_pick_changes.md)
- ["Work In Progress" Merge Requests](wip_merge_requests.md) - [Merge when build succeeds](../user/project/merge_requests/merge_when_build_succeeds.md)
- [Resolve discussion comments in merge requests reviews](../user/project/merge_requests/merge_request_discussion_resolution.md)
- [Resolve merge conflicts in the UI](../user/project/merge_requests/resolve_conflicts.md)
- [Revert changes in the UI](../user/project/merge_requests/revert_changes.md)
- [Merge requests versions](../user/project/merge_requests/versions.md)
- ["Work In Progress" merge requests](../user/project/merge_requests/work_in_progress_merge_requests.md)
- (EE) [Merge Request Approvals](../user/project/merge_requests/merge_request_approvals.md)
- [Repository Mirroring](repository_mirroring.md) - [Repository Mirroring](repository_mirroring.md)
- [Merge When Build Succeeds](merge_when_build_succeeds.md)
- [Manage large binaries with Git LFS](lfs/manage_large_binaries_with_git_lfs.md) - [Manage large binaries with Git LFS](lfs/manage_large_binaries_with_git_lfs.md)
- [Importing from SVN, GitHub, BitBucket, etc](importing/README.md) - [Importing from SVN, GitHub, BitBucket, etc](importing/README.md)
- [Todos](todos.md) - [Todos](todos.md)
# Authorization for Merge requests This document was moved to [user/project/merge_requests/authorization_for_merge_requests](../user/project/merge_requests/authorization_for_merge_requests.md)
There are two main ways to have a merge request flow with GitLab: working with protected branches in a single repository, or working with forks of an authoritative project.
## Protected branch flow
With the protected branch flow everybody works within the same GitLab project.
The project maintainers get Master access and the regular developers get Developer access.
The maintainers mark the authoritative branches as 'Protected'.
The developers push feature branches to the project and create merge requests to have their feature branches reviewed and merged into one of the protected branches.
Only users with Master access can merge changes into a protected branch.
### Advantages
- fewer projects means less clutter
- developers need to consider only one remote repository
### Disadvantages
- manual setup of protected branch required for each new project
## Forking workflow
With the forking workflow the maintainers get Master access and the regular developers get Reporter access to the authoritative repository, which prohibits them from pushing any changes to it.
Developers create forks of the authoritative project and push their feature branches to their own forks.
To get their changes into master they need to create a merge request across forks.
### Advantages
- in an appropriately configured GitLab group, new projects automatically get the required access restrictions for regular developers: fewer manual steps to configure authorization for new projects
### Disadvantages
- the project need to keep their forks up to date, which requires more advanced Git skills (managing multiple remotes)
# Cherry-pick changes This document was moved to [user/project/merge_requests/cherry_pick_changes](../user/project/merge_requests/cherry_pick_changes.md).
> [Introduced][ce-3514] in GitLab 8.7.
---
GitLab implements Git's powerful feature to [cherry-pick any commit][git-cherry-pick]
with introducing a **Cherry-pick** button in Merge Requests and commit details.
## Cherry-picking a Merge Request
After the Merge Request has been merged, a **Cherry-pick** button will be available
to cherry-pick the changes introduced by that Merge Request:
![Cherry-pick Merge Request](img/cherry_pick_changes_mr.png)
---
You can cherry-pick the changes directly into the selected branch or you can opt to
create a new Merge Request with the cherry-pick changes:
![Cherry-pick Merge Request modal](img/cherry_pick_changes_mr_modal.png)
## Cherry-picking a Commit
You can cherry-pick a Commit from the Commit details page:
![Cherry-pick commit](img/cherry_pick_changes_commit.png)
---
Similar to cherry-picking a Merge Request, you can opt to cherry-pick the changes
directly into the target branch or create a new Merge Request to cherry-pick the
changes:
![Cherry-pick commit modal](img/cherry_pick_changes_commit_modal.png)
---
Please note that when cherry-picking merge commits, the mainline will always be the
first parent. If you want to use a different mainline then you need to do that
from the command line.
Here is a quick example to cherry-pick a merge commit using the second parent as the
mainline:
```bash
git cherry-pick -m 2 7a39eb0
```
[ce-3514]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3514 "Cherry-pick button Merge Request"
[git-cherry-pick]: https://git-scm.com/docs/git-cherry-pick "Git cherry-pick documentation"
# Fast-forward merge This document was moved to [user/project/merge_requests/fast_forward_merge](../user/project/merge_requests/fast_forward_merge.md).
GitLab Enterprise Edition offers a way to accept merge requests without creating merge commits.
If you prefer a linear git history, this might be a good feature for you.
You can configure this on a per-project basis by navigating to the project settings page and selecting the **Only fast-forward merging** checkbox.
![Merge request settings](ff_merge.png)
Now when you visit the merge request page, you will be able to accept it only if a fast-forward merge is possible.
If the target branch is ahead of the source branch, you need to rebase the source branch before you will be able to do a fast-forward merge.
For simple rebase operations, you can use the [Rebase before merge](rebase_before_merge.md) feature.
# Merge Request Approvals This document was moved to [user/project/merge_requests/merge_request_approvals](../user/project/merge_requests/merge_request_approvals.md).
If you want to make sure every merge request is approved by one or more
people, you can enforce this workflow by using merge request approvals.
Merge request approvals allow you to set the number of necessary approvals
and predefine a list of approvers that will need to approve every
merge request in a project.
![Merge request approval](merge_request_approvals/2_approvals.png)
## Configuring Approvals
You can configure the approvals in the project settings, under merge requests.
![Merge Request Approvals in Project Settings](merge_request_approvals/approvals_settings.png)
To enable it, set **Approvals required** to 1 or higher.
### Approvals Required
This sets the amount of approvals required before being able to merge a merge request.
At 0, this disables the feature. Any value above requires that amount of different
users to approve the merge request.
### Reset approvals on push
With this setting turned on, approvals are reset when a new push
is done to the merge request branch.
Turn "Reset approvals on push" off if you want approvals to persist,
independent of changes to the merge request.
### Approvers
At approvers you can define the default set of users that need to approve a
merge request. The author of a merge request cannot be set as an approver for
that merge request.
If there are more approvers than required approvals, any subset of these users
can approve the merge request.
If there are less approvers than required approvals, all the set approvers plus
any other user(s) need to approve the merge request before being able to merge it.
![One specific user and someone else need to approve this merge request](merge_request_approvals/1_named_approval.png)
If the approvers are equal to the amount of required approvals, all the approvers are
required to approve merge requests.
![Two specific users need to approve this merge request](merge_request_approvals/2_named_approvals.png)
Note that approvers can be changed during merge request creation.
## Using Approvals
After configuring Approvals, you will see the following during merge request creation.
![Choosing approvers in merge request creation](merge_request_approvals/approvals_mr.png)
You can change the default set of approvers and the amount of required approvals
before creating the merge request. The amount of required approvals, if changed,
must be greater than the default set at the project level. This ensures that
you're not forced to adjust settings when someone is unavailable for approval,
yet the process is still enforced.
To approve a merge request, simply press the button.
![Merge request approval](merge_request_approvals/2_approvals.png)
# Merge Requests This document was moved to [user/project/merge_requests](../user/project/merge_requests.md).
Merge requests allow you to exchange changes you made to source code
## Only allow merge requests to be merged if the build succeeds
You can prevent merge requests from being merged if their build did not succeed
in the project settings page.
![only_allow_merge_if_build_succeeds](merge_requests/only_allow_merge_if_build_succeeds.png)
Navigate to project settings page and select the `Only allow merge requests to be merged if the build succeeds` check box.
Please note that you need to have builds configured to enable this feature.
## Checkout merge requests locally
### By adding a git alias
Add the following alias to your `~/.gitconfig`:
```
[alias]
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
```
Now you can check out a particular merge request from any repository and any remote, e.g. to check out a merge request number 5 as shown in GitLab from the `upstream` remote, do:
```
$ git mr upstream 5
```
This will fetch the merge request into a local `mr-upstream-5` branch and check it out.
### By modifying `.git/config` for a given repository
Locate the section for your GitLab remote in the `.git/config` file. It looks like this:
```
[remote "origin"]
url = https://gitlab.com/gitlab-org/gitlab-ce.git
fetch = +refs/heads/*:refs/remotes/origin/*
```
Now add the line `fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*` to this section.
It should look like this:
```
[remote "origin"]
url = https://gitlab.com/gitlab-org/gitlab-ce.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*
```
Now you can fetch all the merge requests:
```
$ git fetch origin
From https://gitlab.com/gitlab-org/gitlab-ce.git
* [new ref] refs/merge-requests/1/head -> origin/merge-requests/1
* [new ref] refs/merge-requests/2/head -> origin/merge-requests/2
...
```
To check out a particular merge request:
```
$ git checkout origin/merge-requests/1
```
## Ignore whitespace changes in Merge Request diff view
![MR diff](merge_requests/merge_request_diff.png)
If you click the "Hide whitespace changes" button, you can see the diff without whitespace changes.
![MR diff without whitespace](merge_requests/merge_request_diff_without_whitespace.png)
It is also working on commits compare view.
![Commit Compare](merge_requests/commit_compare.png)
## Merge Requests versions
Every time you push to merge request branch, a new version of merge request diff
is created. When you visit the merge request page you see latest version of changes.
However you can select an older one from version dropdown
![Merge Request Versions](merge_requests/versions.png)
# Merge When Build Succeeds This document was moved to [user/project/merge_requests/merge_when_build_succeeds](../user/project/merge_requests/merge_when_build_succeeds.md).
When reviewing a merge request that looks ready to merge but still has one or more CI builds running, you can set it to be merged automatically when all builds succeed. This way, you don't have to wait for the builds to finish and remember to merge the request manually.
![Enable](merge_when_build_succeeds/enable.png)
When you hit the "Merge When Build Succeeds" button, the status of the merge request will be updated to represent the impending merge. If you cannot wait for the build to succeed and want to merge immediately, this option is available in the dropdown menu on the right of the main button.
Both team developers and the author of the merge request have the option to cancel the automatic merge if they find a reason why it shouldn't be merged after all.
![Status](merge_when_build_succeeds/status.png)
When the build succeeds, the merge request will automatically be merged. When the build fails, the author gets a chance to retry any failed builds, or to push new commits to fix the failure.
When the builds are retried and succeed on the second try, the merge request will automatically be merged after all. When the merge request is updated with new commits, the automatic merge is automatically canceled to allow the new changes to be reviewed.
# Reverting changes This document was moved to [user/project/merge_requests/revert_changes](../user/project/merge_requests/revert_changes.md).
> [Introduced][ce-1990] in GitLab 8.5.
---
GitLab implements Git's powerful feature to [revert any commit][git-revert]
with introducing a **Revert** button in Merge Requests and commit details.
## Reverting a Merge Request
_**Note:** The **Revert** button will only be available for Merge Requests
created since GitLab 8.5. However, you can still revert a Merge Request
by reverting the merge commit from the list of Commits page._
After the Merge Request has been merged, a **Revert** button will be available
to revert the changes introduced by that Merge Request:
![Revert Merge Request](img/revert_changes_mr.png)
---
You can revert the changes directly into the selected branch or you can opt to
create a new Merge Request with the revert changes:
![Revert Merge Request modal](img/revert_changes_mr_modal.png)
---
After the Merge Request has been reverted, the **Revert** button will not be
available anymore.
## Reverting a Commit
You can revert a Commit from the Commit details page:
![Revert commit](img/revert_changes_commit.png)
---
Similar to reverting a Merge Request, you can opt to revert the changes
directly into the target branch or create a new Merge Request to revert the
changes:
![Revert commit modal](img/revert_changes_commit_modal.png)
---
After the Commit has been reverted, the **Revert** button will not be available
anymore.
Please note that when reverting merge commits, the mainline will always be the
first parent. If you want to use a different mainline then you need to do that
from the command line.
Here is a quick example to revert a merge commit using the second parent as the
mainline:
```bash
git revert -m 2 7a39eb0
```
[ce-1990]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1990 "Revert button Merge Request"
[git-revert]: https://git-scm.com/docs/git-revert "Git revert documentation"
# "Work In Progress" Merge Requests This document was moved to [user/project/merge_requests/work_in_progress_merge_requests](../user/project/merge_requests/work_in_progress_merge_requests.md).
To prevent merge requests from accidentally being accepted before they're completely ready, GitLab blocks the "Accept" button for merge requests that have been marked a **Work In Progress**.
![Blocked Accept Button](wip_merge_requests/blocked_accept_button.png)
To mark a merge request a Work In Progress, simply start its title with `[WIP]` or `WIP:`.
![Mark as WIP](wip_merge_requests/mark_as_wip.png)
To allow a Work In Progress merge request to be accepted again when it's ready, simply remove the `WIP` prefix.
![Unark as WIP](wip_merge_requests/unmark_as_wip.png)
...@@ -59,6 +59,12 @@ module API ...@@ -59,6 +59,12 @@ module API
authorize_admin_source!(source_type, source) authorize_admin_source!(source_type, source)
required_attributes! [:user_id, :access_level] required_attributes! [:user_id, :access_level]
## EE specific
if source_type == 'project' && source.group && source.group.membership_lock
not_allowed!
end
## EE specific
access_requester = source.requesters.find_by(user_id: params[:user_id]) access_requester = source.requesters.find_by(user_id: params[:user_id])
if access_requester if access_requester
# We pass current_user = access_requester so that the requester doesn't # We pass current_user = access_requester so that the requester doesn't
......
...@@ -162,6 +162,23 @@ describe API::Members, api: true do ...@@ -162,6 +162,23 @@ describe API::Members, api: true do
end end
end end
## EE specific
shared_examples 'POST /projects/:id/members with the project group membership locked' do
context 'project in a group' do
it 'returns a 405 method not allowed error when group membership lock is enabled' do
group_with_membership_locked = create(:group, membership_lock: true)
project = create(:project, group: group_with_membership_locked)
project.group.add_owner(master)
post api("/projects/#{project.id}/members", master),
user_id: developer.id, access_level: Member::MASTER
expect(response.status).to eq 405
end
end
end
## EE specific
shared_examples 'PUT /:sources/:id/members/:user_id' do |source_type| shared_examples 'PUT /:sources/:id/members/:user_id' do |source_type|
context "with :sources == #{source_type.pluralize}" do context "with :sources == #{source_type.pluralize}" do
it_behaves_like 'a 404 response when source is private' do it_behaves_like 'a 404 response when source is private' do
...@@ -292,6 +309,10 @@ describe API::Members, api: true do ...@@ -292,6 +309,10 @@ describe API::Members, api: true do
let(:source) { project } let(:source) { project }
end end
## EE specific
it_behaves_like 'POST /projects/:id/members with the project group membership locked'
## EE specific
it_behaves_like 'POST /:sources/:id/members', 'group' do it_behaves_like 'POST /:sources/:id/members', 'group' do
let(:source) { group } let(:source) { group }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment