Skip to main content

CLI tool for analyzing git repositories

Project description

๐Ÿ” GitSense

Intelligent Git Repository Analysis at Your Fingertips

A powerful CLI tool that analyzes git repositories to provide actionable insights about code health, team contributions, and commit quality. GitSense helps you understand repository patterns, identify risk hotspots, and maintain high code standards.

Version Python License


โœจ Features

๐Ÿง‘โ€๐Ÿ’ผ Contributor Analytics

  • Top Contributors: Identify your most active team members
  • Ranked by commit count over the repository history
  • Quick insight into team engagement patterns

๐Ÿ”ฅ Risk Hotspot Detection

  • File Churn Analysis: Spot files that change frequently
  • Identify potential stability concerns in your codebase
  • Focus refactoring efforts on high-volatility areas

๐Ÿง  Commit Quality Scoring

  • Intelligent Quality Assessment: Evaluate commit hygiene
  • Detects common bad patterns (vague messages, incomplete descriptions)
  • Scores from 0-100 based on commit message standards
  • Encourages better documentation practices

๐Ÿ“Š Rich Terminal Output

  • Beautiful formatted tables and panels
  • Color-coded results for easy scanning
  • Intuitive visual hierarchy

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/buildandbreak-bnb/gitsense.git
cd gitsense

# Install in development mode
pip install -e .

Basic Usage

# Analyze the current repository
gitsense analyze

# Analyze a specific repository
gitsense analyze /path/to/repo

๐Ÿ“– Usage Examples

Default Analysis (Current Directory)

$ gitsense analyze

This will display:

  • Top 5 Contributors: Shows who has been most active
  • Most Changed Files: Highlights files with high churn
  • Commit Quality Score: Overall assessment of commit messages

Analyze a Specific Repository

$ gitsense analyze ~/projects/my-awesome-project
$ gitsense

Example Output

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚         ๐Ÿš€ GitSense Analysis            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

     Top Contributors
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Name        โ”ƒ Commits โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Alice Chen  โ”‚ 342     โ”‚
โ”‚ Bob Smith   โ”‚ 289     โ”‚
โ”‚ Carol White โ”‚ 156     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ฅ Most Changed Files (Risk Hotspots)
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ File              โ”ƒ Changes โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ src/main.py       โ”‚ 156     โ”‚
โ”‚ tests/test_api.py โ”‚ 98      โ”‚
โ”‚ config/settings.pyโ”‚ 67      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚   ๐Ÿง  Commit Quality Score: 78/100        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ“Š Metrics Explained

Top Contributors

Displays the 5 most active developers by commit count (last 1000 commits). Useful for:

  • Understanding team activity distribution
  • Identifying code owners
  • Recognizing consistent contributors

File Churn (Risk Hotspots)

Shows the 5 most frequently modified files (last 500 commits). Files with high churn may indicate:

  • Areas under active development
  • Unstable or complex code
  • Code that needs refactoring
  • Potential quality issues

Use this to: Focus code reviews, refactoring efforts, and testing on high-churn files.

Commit Quality Score

Analyzes the last 200 commits and assigns a score (0-100) based on:

  • Message Length: Encourages descriptive commit messages (minimum 5 characters)
  • Message Clarity: Flags vague messages like "fix", "update", "stuff", "asdf", "wip"
  • Overall Hygiene: Rewards thoughtful, well-documented commits

Scoring Rules:

  • -1 point: Message shorter than 5 characters
  • -1 point: Weak commit message containing "fix" but too short
  • -2 points: Anti-pattern messages (update, stuff, asdf, wip)

Interpretation:

  • 80-100: Excellent commit practice
  • 60-79: Good, with room for improvement
  • 40-59: Needs attention to commit message quality
  • 0-39: Significant quality concerns

๐Ÿ› ๏ธ Architecture

gitsense/
โ”œโ”€โ”€ __init__.py          # Package initialization
โ”œโ”€โ”€ main.py              # CLI entry point (Typer commands)
โ”œโ”€โ”€ analyzer.py          # Git repository interface
โ””โ”€โ”€ metrics/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ contributors.py  # Top contributors metric
    โ”œโ”€โ”€ churn.py         # File churn analysis
    โ””โ”€โ”€ scoring.py       # Commit quality scoring

Key Components

main.py: CLI interface using Typer

  • Orchestrates analysis workflow
  • Formats and displays results with Rich

analyzer.py: Repository wrapper

  • Loads git repositories safely
  • Provides error handling for invalid paths

metrics/: Analysis engines

  • contributors.py: Author frequency analysis
  • churn.py: File modification tracking
  • scoring.py: Commit message evaluation

๐Ÿ“‹ Requirements

  • Python: 3.8 or higher
  • Dependencies:
    • typer - Modern Python CLI framework
    • rich - Beautiful terminal formatting
    • gitpython - Python Git library

See pyproject.toml for exact version specifications.


๐Ÿ”ง Installation & Development

Clone & Install

git clone https://github.com/buildandbreak-bnb/gitsense.git
cd gitsense
pip install -e .

Verify Installation

gitsense --help

Run Tests (if available)

pytest

๐Ÿ’ก Use Cases

๐Ÿ“ˆ Team Onboarding

Run GitSense to show new team members who the domain experts are and where code changes happen most frequently.

๐ŸŽฏ Code Review Focus

Prioritize deeper reviews for high-churn files identified by file churn analysis.

๐Ÿ“ Quality Improvement

Check commit quality scores regularly to maintain standards and encourage better documentation.

๐Ÿ” Codebase Health Audit

Use GitSense as part of regular repository health assessments.

๐Ÿšจ Identify Risk Areas

Quick identification of unstable areas of the codebase that may need refactoring.


๐Ÿ› Troubleshooting

Error: "Not a git repository"

โŒ Not a git repository.
๐Ÿ‘‰ Run inside a repo or pass a path:
   gitsense analyze /path/to/repo

Solution: Run gitsense inside a git repository or provide the full path:

gitsense analyze /path/to/your/git/repo

Command Not Found

If gitsense command isn't recognized:

# Reinstall in development mode
pip install -e .

๐Ÿšฆ Roadmap

  • Additional metrics (code complexity, test coverage)
  • Export results to JSON/CSV
  • Custom time range filtering
  • Integration with CI/CD pipelines
  • Repository comparison tools
  • Configuration file support
  • Advanced filtering and sorting

๐Ÿค Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

git clone https://github.com/buildandbreak-bnb/gitsense.git
cd gitsense
pip install -e ".[dev]"

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘ฅ Author

Build and Break - Crafting tools for better development


๐Ÿ“ž Support & Feedback


๐Ÿ™ Acknowledgments

Built with:

  • Typer - For elegant CLI creation
  • Rich - For beautiful terminal output
  • GitPython - For git repository interaction

Made with โค๏ธ for developers who care about code quality

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitsense-0.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitsense-0.1.1-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file gitsense-0.1.1.tar.gz.

File metadata

  • Download URL: gitsense-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for gitsense-0.1.1.tar.gz
Algorithm Hash digest
SHA256 870de16d51fdd738dd2c49baeda0cbdef10e9b56ecc7e970918f20f4850948b1
MD5 82ba40dc6faba18b7e9cd54519639f57
BLAKE2b-256 93f022f44cfd68f9765c406cc54aa4f96a3f7fc031d035ff22162a9412cd7bbf

See more details on using hashes here.

File details

Details for the file gitsense-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: gitsense-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for gitsense-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 362626d7c43f8ebd37ea27cedaa8d62be0157c67a5c902ac5eea662b36e76df5
MD5 356ee721cea56e9ebb0cae884c9168ad
BLAKE2b-256 71de3d36167d6770ebc4cf7ce3b65d7ba7c3de25e91237df70356c4298dba8cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page