Installs pre-commit hooks for OCaml projects that run dune fmt automatically
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add pre-commit hook files

+53
+37
.hooks/remove-claude-lines.py
··· 1 + #!/usr/bin/env python3 2 + import sys 3 + import re 4 + 5 + def has_emoji(text): 6 + # Unicode ranges for emojis 7 + emoji_pattern = re.compile( 8 + "[" 9 + "\U0001F600-\U0001F64F" # emoticons 10 + "\U0001F300-\U0001F5FF" # symbols & pictographs 11 + "\U0001F680-\U0001F6FF" # transport & map symbols 12 + "\U0001F1E0-\U0001F1FF" # flags (iOS) 13 + "\U00002702-\U000027B0" # dingbats 14 + "\U000024C2-\U0001F251" 15 + "]+", flags=re.UNICODE) 16 + return bool(emoji_pattern.search(text)) 17 + 18 + def main(): 19 + commit_msg_file = sys.argv[1] 20 + with open(commit_msg_file, 'r', encoding='utf-8') as f: 21 + lines = f.readlines() 22 + 23 + # Check for emojis in the commit message 24 + commit_text = ''.join(lines) 25 + if has_emoji(commit_text): 26 + print("Error: Commit message contains emojis, which are not allowed.", file=sys.stderr) 27 + return 1 28 + 29 + filtered_lines = [line for line in lines if 'claude' not in line.lower()] 30 + 31 + with open(commit_msg_file, 'w', encoding='utf-8') as f: 32 + f.writelines(filtered_lines) 33 + 34 + return 0 35 + 36 + if __name__ == '__main__': 37 + sys.exit(main())
+16
.pre-commit-config.yaml
··· 1 + repos: 2 + - repo: local 3 + hooks: 4 + - id: dune-format 5 + name: Auto format with dune 6 + entry: dune fmt --auto 7 + language: system 8 + files: \.(ml|mli|mll|mly)$ 9 + stages: [pre-commit] 10 + pass_filenames: false 11 + 12 + - id: remove-claude-attribution 13 + name: Remove Claude attribution from commit message 14 + entry: python3 .hooks/remove-claude-lines.py 15 + language: system 16 + stages: [commit-msg]