Add a commit counter rule (errors out when more than 20 commits)
Context
Closes gitlab-org/gitlab#358125 (closed)
What does this MR do?
Add a rule for raising an error when we have more than 20 commits.
What does it look like?
When a branch has more than 20 commits ahead of master
, the following error message will be displayed by Danger:
This MR has more than 20 commits. You need to rebase this branch to have fewer commits.
How to test locally?
- Go to your local GitLab installation
git checkout -b branch_with_21_commits
- Change your
Gemfile
:
# Before
gem 'gitlab-dangerfiles', '~> 3.0', require: false
# After
gem 'gitlab-dangerfiles', git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles', branch: '358125-no_more_than_20_commits'
bundle
- Check:
bundle info gitlab-dangerfiles
should give you version3.1.1
- We'll now create 21 commits on a new branch, and run danger locally:
# Should pass
bundle exec rake danger_local
# Create 21 commits
{
touch test-file.out
i=0
while [ $i -ne 21 ]
do
i=$(($i+1))
echo "$i" >> test-file.out
git add .
git commit -m "This is commit #${i}"
done
}
# Should fail
bundle exec rake danger_local
- Remove local branch:
git checkout master
git branch -D branch_with_21_commits
Edited by David Dieulivol