A powerful Python library for mining and analyzing Git repositories
license last-commit repo-top-language repo-language-count PyPI Downloads
## π Table of Contents
- π Overview
- πΎ Features
- π Project Structure
- π Getting Started
- π Project Roadmap
- π° Contributing
- π License
- π Acknowledgments
GitAnalyzer is a Python library for mining and analyzing Git repositories. It provides a powerful interface for extracting detailed information about commits, developers, and code changes. The tool supports both local and remote repositories, with features including:
- Commit history traversal and filtering
- Code change analysis
- Developer contribution tracking
- Process metrics calculation
- Support for multiple repository analysis
- Flexible Repository Access: Analyze both local and remote Git repositories
- Comprehensive Commit Analysis: Extract detailed information about commits, including:
- Author and committer details
- Modified files and their changes
- Code churn metrics
- Commit relationships
- Developer Analytics: Track developer contributions and experience
- Process Metrics: Calculate various software process metrics
- Multiple Repository Support: Analyze multiple repositories in sequence
- Mailmap Support: Proper handling of author mappings via .mailmap files
- Configurable Filters: Filter commits by:
- Date ranges
- Commit hashes
- Tags
- File types
- Authors
βββ GitAnalyzer/ βββ LICENSE βββ Makefile # Build automation configuration βββ dev-requirements.txt # Development dependencies βββ docs # Documentation directory β βββ Makefile # Documentation build configuration β βββ commit.rst # Commit analysis documentation β βββ conf.py # Sphinx configuration β βββ deltamaintainability.rst # Maintainability metrics docs β βββ git.rst # Git interface documentation β βββ index.rst # Documentation index β βββ intro.rst # Introduction guide β βββ modifiedfile.rst # File modification docs β βββ processmetrics.rst # Process metrics documentation β βββ reference.rst # API reference β βββ repository.rst # Repository handling docs β βββ requirements.txt # Documentation dependencies β βββ tutorial.rst # Usage tutorial βββ gitanalyzer # Main package directory β βββ domain # Core domain models β βββ git.py # Git interface implementation β βββ metrics # Analysis metrics implementations β βββ repository.py # Repository management β βββ utils # Utility functions and helpers βββ pytest.ini # PyTest configuration βββ requirements.txt # Core dependencies βββ setup.py # Package installation setup βββ test-requirements.txt # Testing dependencies βββ tests # Test suite directory βββ integration # Integration tests βββ metrics # Metrics tests βββ test_*.py # Unit test files
GITANALYZER/
__root__
dev-requirements.txtDevelopment dependencies including mypy, flake8, and pytest-cov
pytest.iniPyTest configuration for test suite
test-requirements.txtTesting-specific dependencies
requirements.txtCore package dependencies including GitPython and pytz
MakefileBuild and development automation tasks
setup.pyPackage installation and distribution configuration
gitanalyzer
git.pyCore Git interaction and repository management
repository.pyHigh-level repository analysis interface
metrics
process
commits_count.pyCommit frequency analysis
change_set.pyChange set size metrics
contributors_count.pyContributor participation metrics
contributors_experience.pyDeveloper experience analysis
lines_count.pyCode line modification metrics
hunks_count.pyCode change block analysis
process_metric.pyBase process metric implementation
history_complexity.pyRepository history complexity metrics
code_churn.pyCode churn and volatility metrics
utils
mailmap.pyGit mailmap handling utilities
check_git_version.pyGit version compatibility checker
conf.pyConfiguration management utilities
domain
commit.pyCommit entity model and analysis
developer.pyDeveloper entity model and tracking
Before getting started with GitAnalyzer, ensure your runtime environment meets the following requirements:
- Python: Version 3.8 or higher
- Git: Any recent version
- Operating System: Linux, macOS, or Windows
- Package Manager: pip
Install GitAnalyzer using one of the following methods:
Build from source:
- Clone the GitAnalyzer repository:
β― git clone https://github.com/codingwithshawnyt/GitAnalyzer
- Navigate to the project directory:
β― cd GitAnalyzer
- Install the project dependencies:
β― pip install -r requirements.txt -r dev-requirements.txt -r test-requirements.txt
Here's a basic example of using GitAnalyzer:
from GitAnalyzer import Repository # Initialize repository (local or remote) repo = Repository('path/to/repository') # Traverse commits for commit in repo.traverse_commits(): print(f'Commit: {commit.hash}') print(f'Author: {commit.author.name}') print(f'Date: {commit.author_date}') # Access modified files for modification in commit.modified_files: print(f'Modified file: {modification.filename}') print(f'Changes: +{modification.added_lines}, -{modification.deleted_lines}')
Run the test suite using the following command:
β― pytest
For coverage report:
β― pytest --cov=gitanalyzer
- Core Functionality: Basic commit traversal and analysis
- Process Metrics: Implementation of various process metrics
- Multiple Repository Support: Ability to analyze multiple repositories
- Documentation: Comprehensive documentation with Sphinx
- Additional Metrics: Implementation of more advanced metrics
- Performance Optimization: Improve analysis speed for large repositories
- π¬ Join the Discussions : Share your insights, provide feedback, or ask questions.
- π Report Issues : Submit bugs found or log feature requests for the
GitAnalyzer
project. - π‘ Submit Pull Requests : Review open PRs, and submit your own PRs.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your GitHub account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/codingwithshawnyt/GitAnalyzer
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.'
- Push to GitHub: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the Apache License 2.0 License. For more details, refer to the LICENSE file.
- GitPython: Core Git interaction functionality
- Sphinx: Documentation generation
- pytest: Testing framework
- All contributors who have helped improve GitAnalyzer