A Python tool to fetch commit histories from various Git platforms (GitHub, GitLab, and Bitbucket) for archaeological software research.
- Extract commit histories from GitHub, GitHub Gist, GitLab, and Bitbucket repositories
- Special handling for releases and tags
- Rate limit handling with exponential backoff
- Secure API authentication using environment variables
- CSV output for further analysis
- Comprehensive logging
-
Clone this repository:
git clone https://github.com/yourusername/git-commit-tracker.git cd git-commit-tracker -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set up your
.envfile with API keys:GITHUB_TOKEN=your_github_personal_access_token GITLAB_TOKEN=your_gitlab_token BITBUCKET_USERNAME=your_bitbucket_username BITBUCKET_APP_PASSWORD=your_bitbucket_app_password
-
Create a CSV file with repository information. The CSV should have the following headers:
item_name,description,github,gist,gitlab,bitbucket,launchpad,twitter,youtube,blogpost,cran,pypi,codeberg,website,publication,DOI,author1_name,author2_name,author3_name,author4_name,author5_name,author6_name,category,platform,tag1,tag2,tag3,tag4,tag5,notes,internetarchiveExample content:
item_name,description,github,gist,gitlab,bitbucket repo1,Description 1,username/repo1,,, repo2,Description 2,,username/repo2,, repo3,Description 3,,,username/repo3, repo4,Description 4,,,,workspace/repo4 -
Run the script:
python main.py path/to/your/repositories.csv
If no CSV file is specified, it will default to
repositories.csvin the current directory. -
Check the output in the
outputdirectory. Each repository will have its commit history saved in a CSV file named after theitem_name.
The output CSV files contain the following columns:
item_name: The name of the repository/itemdate: The date of the commitmessage: The first line of the commit messagesha: The commit hashauthor: The author of the commit
Releases and tags are included in the output with special prefixes in the message field (e.g., "RELEASE: v1.0.0" or "TAG: v1.0.0").
Check the commit_tracker.log file for detailed logging information.
Common issues:
- API Rate Limiting: The script handles rate limiting with exponential backoff, but you may still encounter limits if processing many repositories
- Authentication Issues: Ensure your API tokens are correct in the
.envfile - Repository Format Issues: For Bitbucket repositories, ensure they follow the
workspace/repo-slugformat
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.