Skip to main content

A CleverGit-like Git client tool with high-level abstractions

Project description

Project Documentation (CleverGit - Git Client, Python Implementation)

Quick Start

CleverGit provides two ways to interact with your Git repositories:

๐Ÿ–ฅ๏ธ Graphical User Interface (GUI)

Launch the GUI application for an intuitive, visual Git experience:

sgg
# or
python -m clevergit.ui.main

Features:

  • Point-and-click repository management
  • Visual file status display
  • Branch management with drag-and-drop
  • Commit history viewer
  • Dialog-based operations
  • Enhanced Diff Viewer - Professional, SmartGit-inspired code difference presentation
    • Softer color scheme for reduced eye strain
    • Word-level highlighting to spot exact changes
    • Improved visual spacing and separation
    • Side-by-side and unified views
  • Command Palette - Quick search and command execution (Ctrl+P)
    • Search files, commits, and branches with fuzzy matching
    • Execute commands without navigating menus
    • Keyboard-driven workflow

๐Ÿ‘‰ For detailed GUI documentation, see GUI_USAGE.md

๐Ÿ’ป Command Line Interface (CLI)

Use powerful command-line commands for scriptable Git operations:

# View repository status
sg status

# Commit all changes
sg commit all -m "feat: add new feature"

# View commit history
sg log --oneline

# Manage branches
sg branch list
sg branch new feature/auth
sg branch switch main

Features:

  • Fast, efficient terminal-based workflow
  • Scriptable operations
  • Batch processing support
  • Integration with other tools

๐Ÿ Python API

Use CleverGit programmatically in your Python scripts:

from clevergit import Repo

# Open repository
repo = Repo.open(".")

# Check status
status = repo.status()
print(f"Modified files: {len(status.modified)}")

# Create commit
repo.commit_all("fix: resolve issue")

# Branch operations
repo.create_branch("feature/new")
repo.checkout("feature/new")

๐Ÿ“ฆ Installation

# Install from PyPI
pip install clevergit

# (Optional) Install from source for development
git clone https://github.com/petertzy/CleverGit.git
cd CleverGit
pip install -e .

# Verify installation
sgg --version  # GUI version check
sg --version   # CLI version check

1. Project Background & Goals

This project aims to develop an advanced Git client tool CleverGit using Python, with focus on:

  • Provide more user-friendly, higher-level Git operation abstractions
  • Lower the learning curve for daily Git usage (especially complex commands)
  • Support CLI-first, GUI-extensible architecture design

Target users:

  • Developers familiar with Git basics but don't want to memorize commands frequently
  • Users who want to operate Git in Python within scripts / toolchains

2. Design Principles

  1. High-level semantics, not command concatenation Example:

    • repo.commit_all("fix login bug")
    • Instead of git commit -am "..."
  2. Readability first Class names and method names should express "user intent" rather than Git details

  3. Modular & Extensible

    • Decouple CLI / GUI / API
    • Can add TUI / Web UI later
  4. Failure is explainable

    • Convert Git errors to "human-readable" exception messages

3. Technology Stack

  • Python >= 3.10

  • Git calling methods:

    • Preferred: GitPython
    • Fallback: subprocess (for scenarios GitPython doesn't support)
  • CLI framework:

    • typer (recommended, type-friendly)
  • GUI (future):

    • PySide6 or Tkinter

4. Core Feature Planning

4.1 Repository Management

  • Open / Initialize repository
  • Detect repository status
  • Current branch, HEAD status
โœ” Is it a Git repository
โœ” Are there uncommitted changes
โœ” Is it behind / ahead of remote branch

4.2 Status View

  • Modified files
  • Untracked files
  • Staged files
  • Conflicted files

Support:

  • Group by file type
  • Output as structured objects for UI use

4.3 Commit

  • Commit all changes
  • Selective commit (specific files)
  • Auto-generate commit message (optional)
  • Pre-commit checks (lint / test hooks)

4.4 Branch Management

  • List branches (local / remote)
  • Create / Delete / Rename branches
  • Switch branches
  • Display branch relationships (simple DAG)

4.5 Merge & Rebase (High-level Wrapper)

  • Safe merge (detect conflicts)
  • Interactive rebase workflow (step-by-step)
  • Conflict file list + hints

4.6 Remote Repository Operations

  • fetch / pull / push
  • Show commits to be pushed / pulled
  • force push risk warning

4.7 History (Log)

  • Concise log view (like git log --oneline --graph)
  • Filter by author / time / branch
  • Single commit details

5. Project File Structure (Recommended)

clevergit/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ clevergit/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ core/                  # Core Git logic
โ”‚   โ”‚   โ”œโ”€โ”€ repo.py             # Repository object (core entry point)
โ”‚   โ”‚   โ”œโ”€โ”€ status.py           # Status analysis
โ”‚   โ”‚   โ”œโ”€โ”€ commit.py           # Commit logic
โ”‚   โ”‚   โ”œโ”€โ”€ branch.py           # Branch management
โ”‚   โ”‚   โ”œโ”€โ”€ merge.py            # merge / rebase
โ”‚   โ”‚   โ”œโ”€โ”€ remote.py           # fetch / pull / push
โ”‚   โ”‚   โ””โ”€โ”€ log.py              # History records
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ git/                    # Git adapter layer
โ”‚   โ”‚   โ”œโ”€โ”€ client.py           # GitPython / subprocess wrapper
โ”‚   โ”‚   โ””โ”€โ”€ errors.py           # Git errors โ†’ business exceptions
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ cli/                    # CLI layer
โ”‚   โ”‚   โ”œโ”€โ”€ app.py              # Typer entry point
โ”‚   โ”‚   โ”œโ”€โ”€ repo_cmd.py
โ”‚   โ”‚   โ”œโ”€โ”€ commit_cmd.py
โ”‚   โ”‚   โ””โ”€โ”€ branch_cmd.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ui/                     # GUI / TUI (reserved)
โ”‚   โ”‚   โ””โ”€โ”€ __init__.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ models/                 # Domain models (DTO)
โ”‚   โ”‚   โ”œโ”€โ”€ file_status.py
โ”‚   โ”‚   โ”œโ”€โ”€ commit_info.py
โ”‚   โ”‚   โ””โ”€โ”€ branch_info.py
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ formatter.py        # Output formatting
โ”‚       โ””โ”€โ”€ helpers.py
โ”‚
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ test_repo.py
    โ”œโ”€โ”€ test_status.py
    โ””โ”€โ”€ test_commit.py

6. Core Object Design Example

Repo (Core Entry Point)

repo = Repo.open(".")

repo.status()
repo.commit_all("fix: login bug")
repo.create_branch("feature/auth")
repo.checkout("feature/auth")

Design goals:

  • One Repo object = One Git repository
  • Most features start from here

7. CLI Design Example

sg status
sg commit -m "fix bug"
sg branch new feature/auth
sg branch switch main
sg log --oneline

CLI principles:

  • Short commands
  • Don't require users to understand Git detail parameters

8. Error Handling Strategy

  • Git raw errors โ†’ Custom exceptions
  • CLI layer catches exceptions โ†’ User-friendly hints

Example:

โŒ Current branch has uncommitted changes, cannot switch branches
Suggestions:
- Commit changes
- Or use sg stash

9. Future Expansion Directions

  • GUI (graphical interface)

  • AI assistance:

    • Auto-generate commit messages
    • Conflict resolution suggestions
  • Plugin system (hooks)

  • Git Flow / Trunk Based workflow support


10. One-Sentence Project Summary

Wrap Git's "intent layer" in Python, make Git usable like objects, not remembered like incantations.

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

clevergit-0.1.1.tar.gz (119.1 kB view details)

Uploaded Source

Built Distribution

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

clevergit-0.1.1-py3-none-any.whl (153.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clevergit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d9149ddaef72d7af2972e4008eddb32bb4a4b7f80949aa5e365ffd0f5018ee7b
MD5 eb781876e08b38492dee1eef7dcdf5cd
BLAKE2b-256 296ce9e7f33843f1d484177a655e2d00ecd16375d4c2cb2701eb32a313260419

See more details on using hashes here.

File details

Details for the file clevergit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: clevergit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 153.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for clevergit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 510a056fbe0199814a287b78395e7e0ce9bd953accc1c86bb25f7cef21039247
MD5 dd5937d02043ac4b8e821b40320235f2
BLAKE2b-256 d43ce87352f26565033fab9b5c9fd4a0830cba0d0cb2a9789c6dcb57d0ebd846

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