Skip to content

feat: Add --repo flag to automatically clone and replay GitHub repositories #50

@unhappychoice

Description

@unhappychoice

Description

Add a --repo flag that allows users to automatically clone and replay commits from any GitHub repository without manually cloning it first.

Motivation

Users should be able to quickly explore interesting repositories without the overhead of:

  1. Manually finding a suitable directory
  2. Cloning the repository
  3. Navigating to it
  4. Running gitlogue

This feature would make gitlogue more accessible for:

  • Exploring popular open-source projects
  • Presentations and demos
  • Educational purposes
  • Quick previews of project history

Proposed Solution

Usage

# Short GitHub notation
gitlogue --repo ratatui-org/ratatui

# Full GitHub URL
gitlogue --repo https://github.com/rust-lang/rust

# Git URL
gitlogue --repo [email protected]:tokio-rs/tokio.git

Implementation Details

  1. Repository Parsing

    • Parse various Git URL formats
    • Extract owner/repo from GitHub URLs
    • Support GitHub shorthand notation (e.g., owner/repo)
  2. Caching Strategy

    • Clone to ~/.cache/gitlogue/repos/<owner>/<repo>
    • Check if repository already exists before cloning
    • Optionally git pull to update existing clones
    • Add --force-clone flag to force re-clone
  3. Git Operations

    • Use git2 crate for cloning (already a dependency)
    • Show progress during clone operation
    • Handle authentication for private repos (optional)
    • Support shallow clones for faster downloads (--depth 1)
  4. CLI Design

# Basic usage
gitlogue --repo owner/repo

# With options
gitlogue --repo owner/repo --theme nord --speed 20

# Force update
gitlogue --repo owner/repo --force-clone

# Shallow clone
gitlogue --repo owner/repo --shallow

# Specific commit from remote repo
gitlogue --repo owner/repo --commit abc123

Example Implementation

#[derive(Parser, Debug)]
pub struct Args {
    // ... existing fields
    
    #[arg(
        short = 'r',
        long,
        value_name = "REPO",
        help = "Clone and replay a GitHub repository (e.g., owner/repo or https://github.com/owner/repo)"
    )]
    pub repo: Option<String>,
    
    #[arg(
        long,
        help = "Force re-clone even if repository exists in cache"
    )]
    pub force_clone: bool,
    
    #[arg(
        long,
        help = "Perform shallow clone (--depth 1) for faster downloads"
    )]
    pub shallow: bool,
}

Benefits

  1. Easier onboarding - New users can try gitlogue immediately
  2. Demos and presentations - Quick setup for showcasing features
  3. Education - Explore how popular projects evolved
  4. Discovery - Browse commit histories of interesting projects
  5. Parity with GitType - GitType already has this feature

Repository Cache Management

Future enhancements could include:

# List cached repositories
gitlogue repo list

# Remove cached repository
gitlogue repo remove owner/repo

# Clear all cache
gitlogue repo clear

# Update all cached repos
gitlogue repo update

References

Related Issues

Additional Context

This feature would significantly improve the user experience and make gitlogue more accessible for exploring the Git history of any public repository on GitHub.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions