git-find 0.3.2

A tool (cli & lib) to find local git repositories.
Documentation

git-find

License: CC0-1.0 Build Status Build status Crates.io Documentation

A tool (cli & lib) to find local git repositories.

Why

Because I need a tool to list and to reorg my local git repositories.

Usage Cli

$> git find -h
git-find 0.3.2
davidB
A tool (cli & lib) to find local git repositories.

USAGE:
    git-find [FLAGS] [OPTIONS] [DIR]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Verbose mode (-v, -vv, -vvv, etc.) print on stderr

OPTIONS:
    -t, --tmpl <format>    format of the output print on stdout [default: {{ .path.file_name }} {{ .path.full }}
                           {{with .remotes.origin}} {{ .name }} {{.url_full}} {{end}}]

ARGS:
    <DIR>    root directory of the search [default: .]
  • broadcast git status to every repositories
git find -t 'cd {{ .path.full }}; echo "\n\n---------------------------------------------\n$PWD"; git status' | sh

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

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 }}
{{with .remotes.origin}}
PRJ_DST=$HOME/src/{{ .url_host }}/{{ .url_path}}
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
{{end}}

Install

From cargo

With Rust's package manager cargo, you can install via:

cargo install git-find

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
tar -xzvf git-find_0.3.2-x86_64-unknown-linux-gnu.tar.gz
chmod a+x git-find
mv git-find $HOME/bin
rm git-find_0.2.2-linux.tar.gz

From source

git clone https://github.com/davidB/git-find

# Build
cd git-find
cargo build

# Run unit tests and integration tests
cargo test

# Install
cargo install

Related and similar

Some tools to help management of multi repository But not the same features, else no need to re-do.

Informations

Actions (broadcast)

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 https://github.com/emk/rust-musl-builder)
  • optimize