git-find
A tool (cli & lib) to find and broadcast commands on local git repositories.
Why
Because I need a tool to list and to reorg my local git repositories.
Usage Cli
& )
)
<DIR> root
-
sample output with default template (M : Modification uncommitted, U: Untracked)
-
broadcast
git status
to every repositories|
-
clean git repository (to free space)
|
Template format
The template format is a subset of golang text/template.
Possibles values
!! Experimental: values could change with future release !!
- .path
- .file_name
- .full
- .remotes
- .<name_of_remote> : eg 'origin'
- .name
- .url_full
- .url_host
- .url_path
- .<name_of_remote> : eg 'origin'
- .working_paths
- .conflicted : list of path
- .modified : list of path
- .added : list of path
- .deleted : list of path
- .renamed : list of path
- .untracked : list of path
For scripting
- Use explicit template within your script (the default template could change with each release)
- If the template is a shell script (the tips could be used with every interpreter: python, ruby, ...), then you can
# run it directly
|
# generate a script and run it later (maybe after review)
Samples
-
to list local repository
{{ .path.file_name }}\t{{ .path.full }}
-
to list local repository with origin url
{{ .path.file_name }}\t{{ .path.full }}\t{{with .remotes.origin}} {{ .name }} {{.url_full}} {{.url_host}} {{.url_path}} {{end}}
-
to create a sh script to "git fetch" on every repository
cd {{ .path.full }}; echo "\n\n---------------------------------------------\n$PWD"; git fetch
-
to create a sh script to move git repository under $HOME/src (same layout as go workspace)
echo "\n\n---------------------------------------------\n" PRJ_SRC="{{ .path.full }}" {{if .remotes.origin}} PRJ_DST="$HOME/src/{{ .remotes.origin.url_host }}/{{ .remotes.origin.url_path}}" {{else}} PRJ_DST=$HOME/src/_local_/{{ .path.file_name}} {{end}} if [ ! -d "$PRJ_DST" ] ; then read -p "move $PRJ_SRC to $PRJ_DST ?" answer case $answer in [yY]* ) mkdir -p $(dirname "$PRJ_DST") mv "$PRJ_SRC" "$PRJ_DST" ;; * ) ;; esac fi
-
to list repo with some info (the default template of version 0.4.1)
{{with .working_paths}}{{if .conflicted}}C{{else}} {{end}}{{if .modified}}M{{else}}{{if .added}}M{{else}}{{if .deleted}}M{{else}}{{if .renamed}}M{{else}} {{end}}{{end}}{{end}}{{end}}{{if .untracked}}U{{else}} {{end}}{{end}}\t{{ .path.file_name }}\t{{ .path.full }}\t{{with .remotes.origin}} {{ .name }} {{.url_full}} {{end}}
Install
From cargo
With Rust's package manager cargo, you can install via:
Note that rust version 1.26.0 or later is required.
From binaries
!! Experimental !!
The release page includes precompiled binaries for Linux, macOS and Windows.
- download archives for your OS
- unarchive it, and move the executable into the PATH
From source
# Build
# Run unit tests and integration tests
# Install
Related and similar
Some tools to help management of multi repository But not the same features, else no need to re-do.
Informations
- peap/git-global: Keep track of all your git repositories. (I quickly look at the source to estimate my contribution to add features, but the "potentials" changes are too many and could change the goal usage of the tool)
- totten/git-scan: CLI tool for scanning/updating git repos
- fboender/multi-git-status: Show uncommitted, untracked and unpushed changes for multiple Git repos
Actions (broadcast)
- gr - A tool for managing multiple git repositories
- mu-repo, Tool to help working with multiple git repositories (short for Multiple Repositories).
- mr which is a tool to manage all your version control repositories.
- Repo command reference | Android Open Source Project
- jiri - Git at Google
- mateodelnorte/meta tool for turning many repos into a meta repo. why choose many repos or a monolithic repo, when you can have both with a meta repo?
- nosarthur/gita: Manage multiple git repos side by side for sanity
TODO
- find a rust template engine that support calling method (getter) on current field (or contribute to gtmpl as it's a feature of go template)
- internally use stream / queue instead of Vector
- build linux binary with musl (see rust-musl-builder)
- optimize