Philipp Hörist pushed to branch master at gajim / gajim
Commits: 7db8a080 by lovetox at 2022-03-27T00:19:42+01:00 Add git update server-side hook
- - - - - 0bd54254 by lovetox at 2022-03-27T00:24:02+01:00 Update CONTRIBUTING.md
- - - - -
2 changed files:
- + .githooks/update - CONTRIBUTING.md
Changes:
===================================== .githooks/update ===================================== @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import sys +import subprocess + + +ALLOWED_TAGS = ['feat', 'fix', 'perf', 'refactor', 'chore', 'other'] + + +def parse_args() -> tuple[str, str]: + old_ref = sys.argv[2] + new_ref = sys.argv[3] + return old_ref, new_ref + + +def get_commit_subject(sha: str) -> str: + data = subprocess.check_output( + ['git', 'log', '-1', '--pretty=format:%s', sha]) + return data.decode() + + +def get_commit_shas(start_ref: str, end_ref: str) -> list[str]: + arg = f'{start_ref}..{end_ref}' + data = subprocess.check_output(['git', 'rev-list', arg]) + text = data.decode() + text = text.strip() + return text.split('\n') + + +def enforce_message_rules(subject: str) -> None: + tag, subject = subject.split(': ', maxsplit=1) + if tag not in ALLOWED_TAGS: + print('Unknown commit message tag:', tag) + sys.exit(1) + + if not subject[0].isupper(): + print('First letter after tag must be uppercase') + sys.exit(1) + + +def main(args: tuple[str, str]) -> None: + shas = get_commit_shas(*args) + for sha in shas: + subject = get_commit_subject(sha) + enforce_message_rules(subject) + + +if __name__ == "__main__": + args = parse_args() + main(args)
===================================== CONTRIBUTING.md ===================================== @@ -1,3 +1,4 @@ +# Project
If you want to create a fork and use an external account (Github, Google) drop us a message at the Gajim support [group chat](xmpp:gajim@conference.gajim.org?join) so we can give you the necessary rights
@@ -6,6 +7,24 @@ - gajim_1.0 - Stable Gajim 1.0.x branch - gajim_0.16 - Stable Gajim 0.16.x branch
+ +# Commit Messages + If you are not familiar with Git please read the [HowTo](https://dev.gajim.org/gajim/gajim/wikis/development/howtogit)
A good article regarding [good commit messages](https://chris.beams.io/posts/git-commit/) + +Every commit message must be prefixed with one of the following tags: + +- feat +- fix +- perf +- refactor +- chore +- other + +Further the first letter after the tag must be upper case + +Example: + +`feat: New Button which does something`
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/b059dfb254aabd7b1f28c6a49641e392...