Skip to content

Add commit message linter script - #13

Open
Skfnrj wants to merge 2 commits into
intro-to-git:mainfrom
Skfnrj:feature/commit-message-linter
Open

Skfnrj wants to merge 2 commits into
intro-to-git:mainfrom
Skfnrj:feature/commit-message-linter

Conversation

@Skfnrj

@Skfnrj Skfnrj commented Apr 7, 2026

Copy link
Copy Markdown

What I did

I added a bash script that goes through all commit messages and checks if they meet the requirements.

What it checks

  • message length (at least 10 characters)
  • presence of one of the required verbs: add, fix, update, remove, improve

How to test

Run the script in the repo and it will print messages that don’t follow the rules.

Related issue

closes #2

@Skfnrj
Skfnrj force-pushed the feature/commit-message-linter branch from 1839ce0 to 788c41f Compare April 7, 2026 21:54
Comment thread commit-message-linter.sh Outdated
echo "Commit \"$message\": message is too short"
fi

if [[ ! "$message" =~ add|fix|update|remove|improve ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion: the check is case-sensitive, so commit messages like "Add feature" or "Fix bug" might not pass. You could consider making the match case-insensitive

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I updated the script to make the check case-insensitive.

@DilyanaSt DilyanaSt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution looks good and correctly implements the required checks for commit messages. I like how the script iterates through all commits and validates both length and required verbs.
One small suggestion: the check is case-sensitive, so messages like "Added feature" might not be handled as expected. You could consider making it case-insensitive.

@IvoPetrevski IvoPetrevski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well although some commits trigger both cases and are printed on two lines. Might be better to combine the messages and print then on one line when that is the case. Otherwise it doesn't miss any commits that break the rules as far as I can tell.

@aminaballa24-dev

Copy link
Copy Markdown

The script is straightforward and easy to follow. I also like that it checks both the message length and whether one of the required verbs is present.

Comment thread commit-message-linter.sh
@@ -0,0 +1,11 @@
#!/bin/bash

git log --pretty=format:"%s" | while read -r message; do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice use of piping into a while read

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.

Commit message linter

5 participants