Hi all Does somebody know about an extension or a template that enforces to have «consistent» commit messages.
ChatGtp suggested to use --8<---------------cut here---------------start------------->8--- # ~/.hg-hooks/commitcheck.py from mercurial import error def check_commit_message(ui, repo, node, **kwargs): ctx = repo[node] # Decode bytes to string msg = ctx.description().decode('utf-8') if not msg.startswith(('feat', 'fix', 'docs', 'chore', 'test', 'refactor')): raise error.Abort( "⛔ Commit message must start with one of: Add, Change, Remove, Docs, test\n" "💡 Example: 'fix: handle edge case in parser'") --8<---------------cut here---------------end--------------->8--- And to add --8<---------------cut here---------------start------------->8--- commitcheck = ~/.hg-hooks/commitcheck.py [hooks] pretxncommit.checkmessage = python:commitcheck.check_commit_message --8<---------------cut here---------------end--------------->8--- However when the commit message does not contain these words, the error message is rather unpleasant: gg ci -m "Snapshot" --8<---------------cut here---------------start------------->8--- transaction abort! rollback completed ** Unknown exception encountered with possibly-broken third-party extension "commitcheck" (version N/A) ** which supports versions unknown of Mercurial. ** Please disable "commitcheck" and try your action again. ** If that fixes the bug please report it to the extension author. --8<---------------cut here---------------end--------------->8--- Any suggestions? Uwe Brauer -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Mercurial mailing list Mercurial@lists.mercurial-scm.org https://lists.mercurial-scm.org/mailman/listinfo/mercurial