Sign inSign up free

782. Enforce Commit Message Rules With a Hook

medium 20 XP ~10 minHands-on lab

The release tool of /home/student/repos/data-pipeline builds the changelog from commit messages, so they must follow the team's format:

<type>(<scope>)?: <description>

Task

Install a commit-msg hook in this repository so that a commit is rejected (with an explanation on stderr) unless the first line of its message:

  • starts with one of the types feat, fix, docs, refactor, test, chore,
  • optionally followed by a scope in parentheses (fix(api)) and/or ! for breaking changes (feat!, feat(api)!),
  • then : (colon and space) and a description,
  • and is at most 72 characters long.

Merge commits (first line starting with Merge ) are always allowed. Other lines of the message are not checked.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Git Essentials. Next step: Work and Personal Git Identities

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.