Sublime Forum

Conventional Commits

#1

I’ve looked around without any luck, is there a preset for Commit Message.sublime-settings to enforce something like Conventional Commits?

While we’re here, is there a good reference I could bookmark for editing the Commit Message and Preferences settings files?

0 Likes

#2

I think something like enforcing that would be something you need a pre-commit hook for in the repository itself; Merge just directly invokes git commands for you behind the scenes.

That said, you could do something like apply a syntax that highlights commit messages in that format. That would visually distinguish things and at the same time also allow for showing as invalid any parts of a commit message that are not valid. I’m not sure offhand if such a syntax currently exists, though.

Regarding the second part of your question, there is official documentation but it doesn’t cover this. It works similar to Sublime except that it currently lacks the niceties to tell you what options you can apply without having to take extra steps yourself.

1 Like

#3

What I ended up doing was adding this to the commit-subject: area of Git Commit.sublime-syntax

- match: '^((?!(fixup!|squash!))?(\w+)((\()*(\w{0})(\))*)((\):)*) (.+))'
  comment: Not a conventional commit
  scope: invalid

I’m sure there are some cases where it would fail, but it will at least nudge me to write “better” commits.

1 Like