-
-
Notifications
You must be signed in to change notification settings - Fork 95k
Description
-->Idea: Contributor format checker script
🐞 Problem
Some contributors accidentally format their names incorrectly in Contributors.md, which can lead to inconsistent entries or merge conflicts. Examples include missing dashes, misplaced brackets, or incorrect placement in the list.
🎯 Goal
Help contributors validate their entry before submitting a pull request. This will reduce formatting errors and make the contribution process smoother for everyone.
💡 Possible solutions
I created a simple Python script that checks formatting of contributor entries in Contributors.md. It can be run locally before submitting a PR.
import re
def check_contributor_format(line):
pattern = r"^-
[?[A-Za-z0-9 _.-]+]
?$"
return re.match(pattern, line.strip())
def validate_contributors_file(filepath="Contributors.md"):
with open(filepath, "r", encoding="utf-8") as f:
lines = f.readlines()
errors = []
for i, line in enumerate(lines):
if line.startswith("-") and not check_contributor_format(line):
errors.append((i + 1, line.strip()))
if errors:
print("Formatting issues found:")
for line_num, content in errors:
print(f"Line {line_num}: {content}")
else:
print("All contributor entries look good!")
Run the check
validate_contributors_file()
📋 Steps to solve the problem
- Comment below about what you've started working on.
- Add, commit, push your changes.
- Submit a pull request and add this in comments -
Addresses #<put issue number here> - Ask for reviews in comments section of pull request.
- Celebrate your contribution to this project. 🎉