Skip to content

crdx/repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repo

repo is a tool that recursively finds git repositories on a filesystem. It can include only repositories matching certain state (dirty, unpushed) and exclude any that match patterns defined in a configuration file. The two modes of operation are to list paths (ls) or execute (run) commands in the context of the repository.

CLI

Usage:
    repo [options] ls
    repo [options] run [--] <command>...

Find git repository paths starting from the current directory, or from stdin if supplied.
Paths from stdin are always displayed as absolute paths.

Options:
    -d, --dirty          Include only dirty repositories
    -u, --unpushed       Include only unpushed repositories
    -a, --all            Include ignored repositories
    -x, --absolute       Show absolute paths
    -v, --verbose        Show a header for each repository when executing a command
    -i, --interactive    Pause between command executions
    --ignore-errors      Ignore errors when executing commands

Examples

Find repositories you've left uncommitted changes in.

repo -d ls

Find repositories you've left unpushed commits in.

repo -u ls

Push all repositories you've left unpushed commits in.

repo -vu run git push

Check the status of all repositories.

repo -v run -- git status -sb

Run fsck on all repositories.

repo -v run git fsck

Perform garbage collection on all repositories, and show a total file count of the .git directories before and after.

repo run -- bash -c 'find .git/ -type f | wc -l' | paste -sd+ | bc
repo -v run git gc
repo run -- bash -c 'find .git/ -type f | wc -l' | paste -sd+ | bc

Ignore patterns

If a config file containing gitignore patterns exists at $HOME/.config/repo/ignore then absolute repository paths will be matched against this file using the high-performance ignore crate.

As absolute repository paths are used to match against the ignore rules the ignore pattern file should be written as though its root is /, the root of the filesystem. This means that if the pattern contains a / then it must be either absolute or prefixed with a **/ to match.

Example

.cargo/                 # Match ".cargo" as any component of path.
**/.cargo/registry/     # Match just the "registry" subdirectory.
**/.local/share/Trash/  # Ignore trash.

Build

Ensure rust is installed.

cargo build --release

The binary can be found in target/release.

Why not use libgit2 instead of spawning git processes?

When benchmarked the git2 crate performed worse than spawning git processes to do the same job. Yes, this disappointed me too.

Contributions

Open an issue or send a pull request.

Licence

GPLv3.