Merge requests workflow
We welcome merge requests from everyone, with fixes and improvements
to GitLab code, tests, and documentation. The issues that are specifically suitable
for community contributions are listed with the
Accepting merge requests
label, but you are free to contribute to any issue you want.
If an issue is marked for the current milestone at any time, even when you are working on it, a GitLab Inc. team member may take over the merge request in order to ensure the work is finished before the release date.
If you want to add a new feature that is not labeled, it is best to first create
an issue (if there isn't one already) and leave a comment asking for it
to be marked as
Accepting Merge Requests. Please include screenshots or
wireframes of the proposed feature if it will also change the UI.
If you are new to GitLab development (or web development in general), see the how to contribute section to get started with some potentially easy issues.
Merge request guidelines
If you find an issue, please submit a merge request with a fix or improvement, if you can, and include tests. If you don't know how to fix the issue but can write a test that exposes the issue, we will accept that as well. In general, bug fixes that include a regression test are merged quickly, while new features without proper tests might be slower to receive feedback. The workflow to make a merge request is as follows:
- Fork the project into your personal namespace (or group) on GitLab.com.
- Create a feature branch in your fork (don't work off your default branch).
- Write tests and code.
- Ensure a changelog is created.
- If you are writing documentation, make sure to follow the documentation guidelines.
- Follow the commit messages guidelines.
- If you have multiple commits, combine them into a few logically organized commits by squashing them, but do not change the commit history if you're working on shared branches though.
- Push the commit(s) to your working branch in your fork.
- Submit a merge request (MR) to the
mainbranch in the main GitLab project.
- Your merge request needs at least 1 approval, but depending on your changes you might need additional approvals. Refer to the Approval guidelines.
- You don't have to select any specific approvers, but you can if you really want specific people to approve your merge request.
- The MR title should describe the change you want to make.
- The MR description should give a reason for your change.
- If you are contributing code, fill in the description according to the default template already provided in the "Description" field.
- If you are contributing documentation, choose
Documentationfrom the "Choose a template" menu and fill in the description according to the template.
- Use the syntax
Closes #XXX, or
Refs #XXXto mention the issue(s) your merge request addresses. Referenced issues do not close automatically. You must close them manually once the merge request is merged.
- The MR must include Before and After screenshots if UI changes are made.
- Include any steps or setup required to ensure reviewers can view the changes you've made (for example, include any information about feature flags).
- If you're allowed to, set a relevant milestone and labels.
- UI changes should use available components from the GitLab Design System, Pajamas.
- If the MR changes CSS classes, please include the list of affected pages, which
can be found by running
grep css-class ./app -R.
- If your MR touches code that executes shell commands, reads or opens files, or handles paths to files on disk, make sure it adheres to the shell command guidelines
- If your code needs to handle file storage, see the uploads documentation.
- If your merge request adds one or more migrations, make sure to execute all migrations on a fresh database before the MR is reviewed. If the review leads to large changes in the MR, execute the migrations again once the review is complete.
- Write tests for more complex migrations.
- Merge requests must adhere to the merge request performance guidelines.
- For tests that use Capybara, read how to write reliable, asynchronous integration tests.
- If your merge request introduces changes that require additional steps when
installing GitLab from source, add them to
doc/install/installation.mdin the same merge request.
- If your merge request introduces changes that require additional steps when
upgrading GitLab from source, add them to
doc/update/upgrading_from_source.mdin the same merge request. If these instructions are specific to a version, add them to the "Version specific upgrading instructions" section.
- Read and adhere to The responsibility of the merge request author.
- Read and follow Having your merge request reviewed.
If you would like quick feedback on your merge request feel free to mention someone from the core team or one of the merge request coaches. When having your code reviewed and when reviewing merge requests, please keep the code review guidelines in mind. And if your code also makes changes to the database, or does expensive queries, check the database review guidelines.
Keep it simple
Live by smaller iterations. Please keep the amount of changes in a single MR as small as possible. If you want to contribute a large feature, think very carefully about what the minimum viable change is. Can you split the functionality into two smaller MRs? Can you submit only the backend/API code? Can you start with a very simple UI? Can you do just a part of the refactor?
Small MRs which are more easily reviewed, lead to higher code quality which is more important to GitLab than having a minimal commit log. The smaller an MR is, the more likely it will be merged quickly. After that you can send more MRs to enhance and expand the feature. The How to get faster PR reviews document from the Kubernetes team also has some great points regarding this.
Commit messages guidelines
Commit messages should follow the guidelines below, for reasons explained by Chris Beams in How to Write a Git Commit Message:
- The commit subject and body must be separated by a blank line.
- The commit subject must start with a capital letter.
- The commit subject must not be longer than 72 characters.
- The commit subject must not end with a period.
- The commit body must not contain more than 72 characters per line.
- The commit subject or body must not contain Emojis.
- Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body.
- Use issues and merge requests' full URLs instead of short references, as they are displayed as plain text outside of GitLab.
- The merge request should not contain more than 10 commit messages.
- The commit subject should contain at least 3 words.
- If the guidelines are not met, the MR may not pass the Danger checks.
- Consider enabling Squash and merge if your merge request includes "Applied suggestion to X files" commits, so that Danger can ignore those.
- The prefixes in the form of
prefix:are allowed (they can be all lowercase, as long as the message itself is capitalized). For instance,
danger: Improve Danger behaviorand
[API] Improve the labels endpointare valid commit messages.
Why these standards matter
- Consistent commit messages that follow these guidelines make the history more readable.
- Concise standard commit messages helps to identify breaking changes for a deployment or ~"master:broken" quicker when reviewing commits between two points in time.
Commit message template
Example commit message template that can be used on your machine that embodies the above (guide for how to apply template):
# (If applied, this commit will...) <subject> (Max 72 characters) # |<---- Using a Maximum Of 72 Characters ---->| # Explain why this change is being made # |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| # Provide links or keys to any relevant tickets, articles or other resources # Use issues and merge requests' full URLs instead of short references, # as they are displayed as plain text outside of GitLab # --- COMMIT END --- # -------------------- # Remember to # Capitalize the subject line # Use the imperative mood in the subject line # Do not end the subject line with a period # Subject must contain at least 3 words # Separate subject from body with a blank line # Commits that change 30 or more lines across at least 3 files should # describe these changes in the commit body # Do not use Emojis # Use the body to explain what and why vs. how # Can use multiple lines with "-" for bullet points in body # For more information: https://chris.beams.io/posts/git-commit/ # --------------------
Contribution acceptance criteria
To make sure that your merge request can be approved, please ensure that it meets the contribution acceptance criteria below:
- The change is as small as possible.
- Include proper tests and make all tests pass (unless it contains a test
exposing a bug in existing code). Every new class should have corresponding
unit tests, even if the class is exercised at a higher level, such as a feature test.
- If a failing CI build seems to be unrelated to your contribution, you can try
restarting the failing CI job, rebasing from
mainto bring in updates that may resolve the failure, or if it has not been fixed yet, ask a developer to help you fix the test.
- If a failing CI build seems to be unrelated to your contribution, you can try restarting the failing CI job, rebasing from
- The MR initially contains a few logically organized commits.
- The changes can merge without problems. If not, you should rebase if you're the
only one working on your feature branch, otherwise merge
- Only one specific issue is fixed or one specific feature is implemented. Do not combine things; send separate merge requests for each issue or feature.
- Migrations should do only one thing (for example, create a table, move data to a new table, or remove an old table) to aid retrying on failure.
- Contains functionality that other users will benefit from.
- Doesn't add configuration options or settings options since they complicate making and testing future changes.
- Changes do not degrade performance:
they should conform to our Licensing guidelines. See those
instructions for help if the "license-finder" test fails with a
Dependencies that need approvalerror. Also, make the reviewer aware of the new library and explain why you need it.
- The merge request meets the GitLab definition of done, below.
Definition of done
If you contribute to GitLab please know that changes involve more than just code. We use the following definition of done. Your contribution is not done until you have made sure it meets all of these requirements.
- Clear description explaining the relevancy of the contribution.
- Working and clean code that is commented where needed.
- Unit, integration, and system tests that all pass on the CI server.
- Regressions and bugs are covered with tests that reduce the risk of the issue happening again.
- Performance guidelines have been followed.
- Secure coding guidelines have been followed.
Documented in the
- Changelog entry added, if necessary.
- Reviewed by relevant reviewers and all concerns are addressed for Availability, Regressions, Security. Documentation reviews should take place as soon as possible, but they should not block a merge request.
- Merged by a project maintainer.
- Create an issue in the infrastructure issue tracker to inform the Infrastructure department when your contribution is changing default settings or introduces a new setting, if relevant.
- Confirmed to be working in the Canary stage with no new Sentry errors or on GitLab.com once the contribution is deployed.
- Added to the release post, if relevant.
- Added to the website, if relevant.
- Black-box tests/end-to-end tests added if required. Please contact the quality team with any questions.
- The new feature does not degrade the user experience of the product.
Contributions do not require approval from the Product team.
If you add a dependency in GitLab (such as an operating system package) please consider updating the following, and note the applicability of each in your merge request:
- Note the addition in the release blog post (create one if it doesn't exist yet).
- The upgrade guide.
- The GitLab Installation Guide.
- The GitLab Development Kit.
- The CI environment preparation.
- The Omnibus package creator.
- The Cloud Native GitLab Dockerfiles
We allow engineering time to fix small problems (with or without an issue) that are incremental improvements, such as:
- Unprioritized bug fixes (for example, Banner alerting of project move is showing up everywhere)
- Documentation improvements
- Rubocop or Code Quality improvements
Tag a merge request with ~"Stuff that should Just Work" to track work in this area.