Commit and merge request
The syntax and rules for commit messages, the possible type and scope combinations, and how a merge request message differs.
You must add all the files of your solution in only one commit. Read the GitLab
documentation to learn the commit concept.
Commit message
Syntax
Valid commit messages have the structure:
[product]\[type]([scope]): #[issue-number]{.issue-part} [title] // This is the commit title
// This blank line separates the commit title from the commit body
[body] // - This is the commit body. It CAN have multiple lines[variable]is a required variable. Replace it in the final commit message, and remove the [] symbols.{variable}is an optional variable. Replace it or remove it in the final commit message, and remove the {} symbols.// Commentis a comment. Remove all the comments from the final commit message.
Rules
A commit message must obey all these rules.
-
[product] variable must be one of these:
all // Transversal changes that affect several products, // this label will run all existent pipelines app // Changes related with app (front, back, infra) chall // Changes related with challenges solutions files common // Repo-wide registration commits not tied to a single product docs // Changes on documentation (front, back, infra) nix // Changes related with Nix (build, infra) -
[type] variable must be one of these:
rever // Revert to a previous commit in history feat // New feature perf // Improves performance fix // Bug fix refac // Neither fixes a bug or adds a feature test // Adding missing tests or correcting existing tests style // Do not affect the meaning of the code (formatting, etc) chore // Routine task or registration commit sol // Hacking solution only for writeups and training repo -
[scope] variable must be one of these:
front // Front-End change back // Back-End change infra // Infrastructure change conf // Configuration files change build // Build system, CI, compilers, etc (scons, webpack...) job // asynchronous or scheduled tasks (backups, maintenance...) cross // Mix of two or more scopes doc // Documentation only changes vbd // Vulnerable by design hacking solution only for writeups repo code // Programming challenge solution only for training repo hack // CTF-hacking challenge solution only for training repo -
A commit title must exist.
-
A commit title must not contain the
:character. -
A commit title must have 80 characters or less.
-
A commit title must be lower case.
-
A commit title must not finish with a dot
.. -
A commit title must reference an issue.
-
A commit title must give information. Do not write a title such as
app\feat(build): #5.1 feature. -
If a commit title has sol type, it must reference issue #0.
-
If a commit title has sol type, the part after
#0must have one of these two shapes:<site-name>, <chall-code> (<complexity>)for acodescope or for ahackscope.<site-name>, <chall-code>for avbdscope.
A comma and one space separate the two names, and one space precedes the parenthesis. Each name accepts only lowercase letters, digits and hyphens.
-
A commit body must exist. One blank line, and only one, separates the body from the title. The body tells what the commit changes.
-
A commit body must have 15 characters or more.
-
Each line in the commit body must start with
-, a dash and a space, for a new item. To continue the previous item, start the line with a space. The commit body does not accept a paragraph of prose. -
Lines in the commit body must have 72 characters or less.
-
Your branch must be ahead of
masterby exactly one commit. If you made more than one, squash them into one before you push.
Possible combinations
This table gives all the possible combinations of type and scope for a commit message. The columns are the types, and the rows are the scopes.
| rever | feat | perf | fix | refac | test | style | |
|---|---|---|---|---|---|---|---|
| front | Revert front-end to a previous version | Add new feature to front-end | Improve perf in front-end | Fix something in front-end | Change something in front-end | Add tests for front-end | Change front-end code style |
| back | Revert back-end to a previous version | Add new feature to back-end | Improve perf in back-end | Fix something in back-end | Change something in back-end | Add tests for back-end | Change back-end code style |
| infra | Revert infra to a previous version | Add new feature to infra | Improve perf in infra | Fix something in infra | Change something in infra | Add tests for infra | Change infra code style |
| conf | Revert config files to a previous version | Add new feature to config files | NA | Fix something in config files | Change something in config files | NA | Change config files code style |
| build | Revert building tools to a previous version | Add new feature to building tools or add a new building tool | Improve building perf | Fix something in building tools | Change something in building tools | Add tests for building tools | Change building tools code style |
| job | Revert jobs to a previous version | Add new feature to jobs or add a new job | Improve jobs perf | Fix something in jobs | Change something in jobs | Add tests for jobs | Change jobs code style |
| cross | Revert some scopes to a previous version | Add new feature for some scopes | Improve perf in some system parts | Fix something in some system parts | Change something in some system parts | Add tests for some system parts | Change code style in some system parts |
| doc | Revert doc to a previous version | Add new doc | NA | Fix something in doc | Change something in doc | NA | Change doc style |
Where:
- perf is performance.
- infra is infrastructure.
- conf is configuration.
- doc is documentation.
- NA is not applicable.
Recommendations
-
Write your commit body as a list of items:
- Add feature X in file Y - Run script Z - Remove file A with B purpose -
Do not use the word part when you divide the commits or the merge requests of one issue. Use
#[issue-number]{.issue-part}. The example below shows it.
Example
This is an example of a correct commit message. The issue number has .1 after
it, because this commit is part 1 of the solution of the issue:
nix\feat(build): #13.1 add type_check
- Add type_check function
- Remove unnecessary print_output functionThe repository has two templates for challenges: the hacking-ctf and code template and the hacking VbD template. This is an example for code:
chall\sol(code): #0 codeabbey, 001 (1.00)
- Dart solutionThe first contribution of a talent to the repository is the registration
commit. That commit contains the .mailmap entry and the
users/<assigned-nickname>.yml file. This is its commit message:
common\chore(conf): #0 first commit
- register <assigned-nickname>See First commit for the full flow.
Merge request
When your commit passes all the pipelines, you can open a merge request to the master branch. A complete and correct pipeline shows the color green. If a reviewer rejects the merge request, do not open it again. Correct the errors and send the new solution in a new merge request.
Differences from commit messages
A merge request message is the same as a commit message, with two differences:
-
The
[type]of the merge request must be the most relevant type of all its commits. This is the relevance list:rever feat perf fix refac test style solreverhas the highest relevance, andsolhas the lowest. For example, your merge request has onefeatcommit, onetestcommit and onestylecommit. Then its[type]must befeat. -
The merge request message can have a
Closes #{issue-number}line in its footer. This line is not necessary. When a reviewer accepts the merge request, GitLab closes the issue automatically.
Merge request example
This is an example of a correct merge request message:
app\feat(build): #13.3 new checks to the pipeline
- Add type_check
- Add deltas_check
- Add commit_number check
Closes #13The Closes #13 footer closes issue 13 automatically, when a reviewer accepts
this merge request.