Skip to content
Snippets Groups Projects
gitflow.md 4.14 KiB
Newer Older
# Gitflow

## Protecting branches

Protected branches prevents anyone from pushing. The only way to push on a branch is with **merge requests**.

## Branch naming

With **Factory** process, we have issues listed on gitlab and we can create merge requests and branches from issues. The default branch name is the title of the issue. Try to **shorten** the branch name and translate it to **english**.

:::tip Example of branch naming
Issue 299 named "*[Eau/ Elec/ Prix/Backoffice] Non prise en compte d'un nouveau prix/nouvelle date dans changement prix d'un fluide dans la modale estimation des prix*"

The default branch name would be **`299-eau-elec-prix-backoffice-non-prise-en-compte-d-un-nouveau-prix-nouvelle-date-dans-changement`** which is quite long and not so convenient in your editor.

Try to shorten by using **key words**, for example : **`feat/latest-prices-in-estimation-modal`**
:::

:::tip branch folders
If your branches contains "/", it will create folders.
This can be useful to sort `feat` and `fix`
:::

## Merge requests

:::tip Name you merge request with the desired conventional commit
By naming your merge request the desired conventional commit, it will be easier when merging by clicking the "Edit commit message"
:::
Follow the `merge_request_template` when creating a merge request. Make sure to update it as you code to indicate the reviewer what changed and what is necessary to test.

It is important that you **squash** your commits when merging. The box is checked by default. Make sure to use a **conventional commit**.

## Conventional commit

The [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary) is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.

The commit message should be structured as follows:

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

The commit contains the following structural elements, to communicate intent to the consumers of your library:

- **fix**: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
- **feat**: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
- **BREAKING CHANGE**: a commit that has a footer BREAKING CHANGE:, or appends a `!` after the type/scope, introduces a breaking change (correlating with MAJOR in Semantic Versioning). Give a solid description of the changes as well.
- types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the the Angular convention) recommends `build:`, `chore:`, `ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, and others.
- footers other than BREAKING CHANGE: description may be provided and follow a convention similar to git trailer format.

:::note Respecting conventional commits
By respecting conventional, you ensure that :

- the [changelog](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/CHANGELOG.md) stays up to date
- the feature/fix you worked on is listed in the changelog

📝 While adhering to the conventional commit guidelines, you have the option to exclude specific commits from appearing in the changelog. To do so, use `chore(scope): message`.
:::

## Gitflow Scheme

```mermaid
%%{init: { 'theme': 'base', 'themeVariables': { 'tagLabelFontSize': '16px' } }}%%
---
title: Gitflow for Ecolyo
---
gitGraph
commit id: "release 1.1.0" tag: "v1.1.0"
branch dev
checkout dev
commit id: "previous commits"
branch feat-conso
commit id: "feat(conso): add compare data" type: HIGHLIGHT
checkout dev
commit id: "feat(analysis): something"
checkout feat-conso
merge dev
commit id: "Merge dev into feat-conso"
checkout dev
merge feat-conso

branch fix-conso
checkout fix-conso
commit
commit id: "fix(conso): update colors"
checkout dev
commit id: "📚 doc - project description"
merge fix-conso
commit id: "release 1.2.0" tag: "v1.2.0"

checkout main
merge dev
```