A Python script that tracks and logs files modified in a GitHub repository within a specified date range. This tool is particularly useful for:
- Tracking file changes across multiple commits
- Generating reports of modified files
- Analyzing repository activity
- Maintaining a history of file modifications
- 🔍 Tracks files modified in GitHub commits
- 📅 Filters commits by date range
- 📝 Generates daily log files
- 🔄 Handles GitHub API rate limits
- ⚡ Implements retry logic for failed requests
- 📊 Provides detailed logging
- Python >=3.13
- uv - Fast Python package installer and resolver
- A GitHub account
- A GitHub Personal Access Token
- Clone the repository:
git clone <your-repo-url>
cd python-git-files- Install dependencies using uv:
uv sync- Create and activate a virtual environment using uv:
uv venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate- Copy the environment sample file:
cp .env.sample .env- Update the
.envfile with your GitHub credentials:
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_REPO=your_repository_name
GITHUB_REPO_OWNER=your_github_username
GITHUB_REPO_BRANCH=main # or your default branch- To create a GitHub Personal Access Token:
- Go to GitHub Settings > Developer Settings > Personal Access Tokens
- Generate a new token with
reposcope - Copy the token and paste it in your
.envfile
- Run the script:
uv run main.py- The script will:
- Fetch commits within the specified date range
- Track modified files in each commit
- Generate a log file in the
git-filesdirectory - Create detailed logs in the
logsdirectory
The script generates two types of outputs:
-
Git Files Log (
git-files/YYYY-MM-DD.txt):- Contains a list of all modified files
- One file per line
- Sorted alphabetically
- Excludes binary files and old versions
-
Application Logs (
logs/):- Detailed execution logs
- API request information
- Error messages and warnings
- Rate limit handling
You can modify the following parameters in main.py:
DATE_RANGE: Change the date range for commit trackingMAX_RETRIES: Adjust the number of retry attempts for failed requestsRATE_LIMIT_DELAY: Modify the delay between API calls
The script includes robust error handling for:
- Network issues
- API rate limits
- Invalid configurations
- File system errors
Logs are stored in the logs directory with:
- Timestamp
- Log level
- Detailed messages
- Error stack traces (if any)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the logs in the
logsdirectory - Review the error messages
- Open an issue in the repository
- Keep your GitHub token secure
- Regularly update your dependencies
- Monitor your API usage
- Back up your log files
- Review the generated files regularly
This project uses modern Python tooling:
- Python >=3.13 for enhanced performance and features
uvfor fast dependency management.env.samplefor environment variable documentation- Type hints for better code maintainability