I want to make an executable for shell or bash that will scan the entire directory for git repositories
find . ! -readable -prune -o -name ".git" -type d -prune -print
Then run (changing directory from --git-dir
)
git --git-dir="/var/www/miRepo/.git" fetch --all -q
then something like this
git --git-dir="/var/www/miRepo/.git" diff --stat | tail -n1
I would like to be able to have statistics on the state of the repo something like
Ramas Remotas | Ramas Locales | Cambios (new-mod-del) | código
master master M 123 - A 1 - D 1 - R 12 - C 12 (+)1223 (-)122
production | no seguimiento
That the changes be summarized according to the states of git status
the documentation . I would like to have a file of type sh that receives the directory as a parameter. But I do not exclude other solutions in other languages, since they serve as a base to do what I want.
You have a good part of the commands, so you only need to join them and go over the results.
This can be done by using process substitution to feed the loop with the output of
find
:In this case you can pass the directory to the script as a parameter:
See a sample run:
I'll leave it as an exercise to dissect the output of the data so that it fits the format you would like to have.