Recently, I have developed a gitLab-based collaboration specification for release (non-continuous integration) based on Git-Flow, which can be used as a reference.
Branch specification
We have the following branches:
- Master: All stables on the master are production-ready.
- Develop: As the main branch of development, all The Mrs Should be merged into the Develop branch and periodically merged into master releases.
- Release -* : LTS versions need to have separate branches for subsequent (in case) hotfixes, down to minor versions such as release-v1.2, which are long-held branches.
- Feature /* : All new features (such as new features and performance optimizations) should checkout to a new feature branch first.
- Bugfix /* : A bugfix branch, which must be merged into the Develop branch only.
- Test /* : The test branch does three things: 1. 2. Modify the store-level configuration file (for example,.gitlab-ci.yml). 3. Used to host one-off tests (outside develop).
- Hotfix /* : The branch used to publish hotfixes, see the next section.
- Release /* : a branch used to do release work (e.g., update version numbers, bugfix), and also to freeze the feature, as shown in the next section.
Branch names should be named with underscores. The branch name will be forcibly checked in CI and fail if it is not compliant. The test/* branch is also set aside to support testing work that can pass CI checks.
Collaborative process
The development process
- First, make sure you’re on the Develop branch;
- Git checkout -b feature/your_feature;
- After development is complete, push to Origin;
- Select Mr, target Branch as Develop and check the bottom two options:
5. Wait for review to pass and click Merge. Check that Squash and Delete branch are checked again:6. If the merge request has a description, click “Modify Commit message” and click include Description at the bottom, then click merge:7. Done.
Bugfix process
Develop the bugfix
- First, make sure you’re on the Develop branch;
- Git checkout -b bugfix/your_bugfix;
- After development is complete, push to Origin;
- Select Mr, Target branch as Develop, and check the bottom two options as in the development process.
- After review passes, click Merge. Check that Squash and Delete Branch are checked again.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Done.
Bugfix release / *
There is no need to merge directly back to Develop because release/* will eventually merge back to Develop.
- First, make sure you’re on the Release/vx.y.z branch;
- Git checkout -b bugfix/your_bugfix;
- After development is complete, push to Origin;
- Select Mr, Target branch as Release/vx.y.z, and check the bottom two options as in the development process.
- After review passes, click Merge. Check that Squash and Delete Branch are checked again.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Done.
Hotfix process
You need to merge into Develop
- Follow the normal Bugfix process and update the version number in your code (in case you forget to merge back to Develop after merging to master).
- Switch to the master branch;
- Git checkout -b hotfix/your_hotfix;
- Cherry-pick bugfix commit;
- After checking, push to Origin;
- Select Mr, Target Branch as master, and check the bottom two options as in the development process.
- After review passes, click Merge. Check that Squash and Delete Branch are checked again.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Go to the Master branch and type a new tag;
- Done.
You just merge into the master
This works if the bug you need to fix no longer exists on the Develop branch.
Updates to the version number do not need to be synchronized to Develop; conflicts can be resolved during the next merge.
- First, make sure you’re on the Master branch;
- Git checkout -b hotfix/your_hotfix;
- After the fix is complete, add a separate COMMIT, update the version number in the code, push to Origin;
- Select Mr, Target Branch as master, and check the bottom two options as in the development process.
- After review passes, click Merge. Check that Squash and Delete Branch are checked again.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Go to the Master branch and type a new tag;
- Add the separate Commit cherry-pick from Step 3 to the Develop branch with the updated version number;
- Done.
You need to merge into LTS Release Branch
- Depending on the situation, the completion needs to be merged into Develop or just one of the master;
- Switch to the release-vx. Y branch (the branch to be fixed);
- Git checkout -b hotfix/your_hotfix;
- Cherry-pick hotfix commit;
- Update the version number in the code, check it and push it to Origin;
- Select Mr, target branch as release-vx. Y, and check the bottom two options as in the development process.
- After review passes, click Merge. Check that Squash and Delete Branch are checked again.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Switch to the release-vx. Y branch and type a tag;
- Done.
Release process
The release process is quite special, which is quite different from other processes. Please pay attention to details.
The reason for doing this is that if you merge the Release Branch into the Develop branch and then merge the Develop branch into the master, There may be an unexpected commit (a new Mr Is merged into Develop during a collating release).
- First, make sure you’re on the Develop branch;
- Git checkout -b release/ vx.y.z;
- Do some work required for release (update version number, etc.);
- When you’re done, push to Origin;
- If Mr, target branch is master, squash and remove source branch are not checked **.
- After review passes, click Merge. Check that Squash and Delete Branch are not selected.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Switch to Master and type a vx.y.z tag.
- Target branch = develop, ** uncheck squash, check Remove source branch**;
- After review passes, click Merge to check that Squash is not checked, but Delete Branch is checked.
- If the merge request has a description, click “Modify Commit Message” and click include Description at the bottom, then click Merge.
- Done.
CI check script
#!/usr/bin/env bash
echo "branch name is: $1"
if[[! $1 =~ ^(((feature|bugfix|test|hotfix)/.+)|(master|develop)|(release-v[0-9] + \.0-9]+)|(release/v[0-9] + \.0-9] + \.0-9]+(-[a-z0-9.]+(\+[a-z0-9.] +)? ?). ) $]]; then echo"branch name invalid!"> &2
exit 1
fi
Copy the code