Browse Source

Add Text-Based Contribution Tracking System

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 month ago
parent
commit
011830ee34
3 changed files with 115 additions and 0 deletions
  1. 9 0
      scripts/CONTRIBUTORS.md
  2. 42 0
      scripts/README.md
  3. 64 0
      scripts/update_contributors.py

+ 9 - 0
scripts/CONTRIBUTORS.md

@@ -0,0 +1,9 @@
+# 🌍 Project Contributors
+
+This file lists all contributors automatically extracted from Git commit history.
+Do not edit manually — run `python scripts/update_contributors.py` to refresh.
+
+| Name | Email | Contributions | First Commit | Last Commit | Reference |
+|------|--------|----------------|---------------|--------------|-----------|
+| Adam Djellouli | [email protected] | 1 commits | 2025-10-29 | 2025-10-29 |  |
+| copilot-swe-agent[bot] | [email protected] | 1 commits | 2025-10-29 | 2025-10-29 |  |

+ 42 - 0
scripts/README.md

@@ -64,6 +64,48 @@ If you encounter MSVC issues, ensure "Desktop development with C++" is installed
 
 
 ---
 ---
 
 
+## Contributor Tracking
+
+### `update_contributors.py` - Contributor Tracking Script
+
+Automatically generates and maintains a `CONTRIBUTORS.md` file based on Git commit history. This script uses Git as the single source of truth for contributor information.
+
+**Features:**
+- ✓ Extracts contributor names, emails, and commit dates from Git history
+- ✓ Counts total commits per contributor
+- ✓ Tracks first and last contribution dates
+- ✓ Generates formatted Markdown table
+- ✓ Includes optional reference link column (manual editing supported)
+- ✓ No external dependencies beyond Git and Python 3
+
+**Requirements:**
+- Python 3.7+
+- Git
+
+**Usage:**
+```bash
+# Update contributor list
+python scripts/update_contributors.py
+```
+
+**Output:**
+- File: `scripts/CONTRIBUTORS.md`
+- Contains a Markdown table with contributor information
+
+**Example Output:**
+```markdown
+# 🌍 Project Contributors
+
+| Name | Email | Contributions | First Commit | Last Commit | Reference |
+|------|--------|----------------|---------------|--------------|-----------|
+| Alice Dev | [email protected] | 42 commits | 2024-03-11 | 2025-10-28 |  |
+| Bob Writer | [email protected] | 9 commits | 2025-03-15 | 2025-10-20 |  |
+```
+
+**Note:** The Reference column is left empty by default and can be manually edited to add links to GitHub profiles, websites, or other references. However, manual edits will be preserved only if the contributor's row remains unchanged in subsequent updates.
+
+---
+
 ## Linux/macOS Scripts
 ## Linux/macOS Scripts
 
 
 ### `setup-deps.sh` - Dependency Installer
 ### `setup-deps.sh` - Dependency Installer

+ 64 - 0
scripts/update_contributors.py

@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+import subprocess
+import datetime
+from collections import defaultdict
+from pathlib import Path
+
+# Path to CONTRIBUTORS.md
+contributors_file = Path(__file__).parent / "CONTRIBUTORS.md"
+
+def run_git(command):
+    """Run a git command and return the output as a list of lines."""
+    result = subprocess.run(
+        ["git"] + command, capture_output=True, text=True, check=True
+    )
+    return result.stdout.strip().split("\n")
+
+def get_contributors():
+    """Extract contributors from git log."""
+    log_lines = run_git(["log", "--format=%aN|%aE|%ad", "--date=short"])
+    contributors = defaultdict(lambda: {"emails": set(), "first": None, "last": None, "count": 0})
+
+    for line in log_lines:
+        if "|" not in line:
+            continue
+        name, email, date = line.split("|")
+        name, email = name.strip(), email.strip()
+        info = contributors[name]
+
+        info["emails"].add(email)
+        info["count"] += 1
+        if not info["first"] or date < info["first"]:
+            info["first"] = date
+        if not info["last"] or date > info["last"]:
+            info["last"] = date
+
+    return contributors
+
+def generate_table(contributors):
+    """Generate markdown table."""
+    header = [
+        "# 🌍 Project Contributors",
+        "",
+        "This file lists all contributors automatically extracted from Git commit history.",
+        "Do not edit manually — run `python scripts/update_contributors.py` to refresh.",
+        "",
+        "| Name | Email | Contributions | First Commit | Last Commit | Reference |",
+        "|------|--------|----------------|---------------|--------------|-----------|",
+    ]
+    rows = []
+    for name, info in sorted(contributors.items(), key=lambda x: x[0].lower()):
+        emails = ", ".join(sorted(info["emails"]))
+        # Default empty reference link
+        reference = ""
+        rows.append(f"| {name} | {emails} | {info['count']} commits | {info['first']} | {info['last']} | {reference} |")
+    return "\n".join(header + rows) + "\n"
+
+def main():
+    contributors = get_contributors()
+    md = generate_table(contributors)
+    contributors_file.write_text(md, encoding="utf-8")
+    print(f"✅ Updated {contributors_file} with {len(contributors)} contributors.")
+
+if __name__ == "__main__":
+    main()