feat: add script to fetch contributor analytics from GitLab project
Summary
This merge request adds a Python script that uses the GitLab API to fetch contributor analytics for a given project ID on code.swecha.org.
Features
- Accepts GitLab project ID as input
- Fetches contributor details including:
- Name
- Number of commits
- Additions
- Deletions
- Reads GitLab token and base URL securely from
.envfile usingpython-dotenv
Environment Setup
-
Create a
.envfile in the root directory with: GITLAB_TOKEN=your_access_token GITLAB_API_URL=https://code.swecha.org/api/v4 -
Install dependencies: Pip install requests
-
Run the script: python contAnalytics.py
Additional Notes
-
.envfile is added to.gitignoreto keep sensitive credentials safe. - The script includes proper error handling for HTTP responses like 401 and 404.
Checklist
-
Token-based authentication -
Reads environment variables from .env -
Handles invalid tokens and private projects -
Uses semantic commit message