← All challenges

// code challenge

Commit message linter

~12 min

Enforce a team's commit convention with ten lines of Python.

Your team requires commit messages shaped like `type: subject` where:

- `type` is one of: `feat`, `fix`, `docs`, `chore` - a colon and a single space follow the type - the subject is non-empty and the TOTAL length is ≤ 50 characters

Read one commit message from stdin. Print `OK` if it passes, otherwise `REJECTED`.

Examples: ``` fix: raise db timeout to 5s → OK update stuff → REJECTED (no valid type) feat:no space → REJECTED (missing space) ``` Hint: `msg.split(": ", 1)` and check the parts.

Language: python · Judge0

// sample tests

  • stdin "fix: raise db timeout to 5s"stdout "OK"
  • stdin "update stuff"stdout "REJECTED"
  • stdin "feat:no space"stdout "REJECTED"

Sign in to run and submit.

Commit message linter