Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add commit branch validation #97

Merged
merged 23 commits into from
Feb 3, 2024

Conversation

ArthurHtbk
Copy link
Contributor

In an effort to put an end to the observed resurgence of sloppy commit messages and branch names amongst my students -such as git commit -m "booger aids" or even git checkout -b nouvelle_feature_a_gillou-, I took it upon myself to add those validations as pre-commit hooks via Husky.

Commit message validation

The expected format adheres to the Conventional Commits set of specifications. It goes as follows:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

The <type> can be feat: , fix: or others like build: , chore: ,ci: , docs: , style: , refactor: , perf: , test: . The <description> is a short message written using imperative mode (add last feature [...] instead of added for example) that effectively and accurately depicts the changes being made. The body and footers are optional and, IMHO, not necessary at this point of the training.

Branch name validation

I didn't follow the <type>/message-in-kebab-case convention because I would like my students to create one branch per user story. The expected format goes like this: S{number}US{number}/message-in-kebab-case (example: S3US14/fix-header). Feel free to adapt the validation pattern as you see fit! The regex: ^S\\d{1}US\\d{1,2}\/[a-z0-9]+(-[a-z0-9]+)*$.

Hope you like it!

@rocambille
Copy link
Collaborator

rocambille commented Oct 9, 2023

you have to update pnpn lock files as well ;)

@ArthurHtbk
Copy link
Contributor Author

Yay!!! 🥳 📦

@rocambille
Copy link
Collaborator

rocambille commented Jan 28, 2024

Time to manage this one :)

Here are some propositions:

  • Configure branch name validation with a "match anything" regex /.*/ by default (so the hook always pass) : defining a real pattern implictly turns on the validation
  • Propose some kind of on/off button for commitlint

@rocambille rocambille merged commit 4612a86 into dev Feb 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants