From 25ce97a7f8c6f56eb67af22d06311f8709d5d919 Mon Sep 17 00:00:00 2001 From: drymer Date: Sun, 10 Jun 2018 21:30:58 +0200 Subject: [PATCH] Add recursion to git_updated function This way it's possible to use the function to check subdirectories --- roles/shell-dotfiles/files/functions | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/roles/shell-dotfiles/files/functions b/roles/shell-dotfiles/files/functions index 07622f9..161833d 100644 --- a/roles/shell-dotfiles/files/functions +++ b/roles/shell-dotfiles/files/functions @@ -81,22 +81,30 @@ function kenter(){ kubectl exec -ti $1 $2 $3 $command } -# Comprueba que los repositorios git de un repositorio tienen commits a hacer +# Check that the directories of the main directory are updated git repos function git_updated() { - for git in `ls --color=none` + local ROOT=`pwd` + local gitstatus + + for dir in `ls --color=none | grep -v Archive` do - if [[ -d $git ]] - then - cd $git - gitstatus="`git status -s | awk '{print $2}'`" - - if [[ -n $gitstatus ]] + if [[ -d $dir ]] then - echo "- \033[0;31m$git\033[0m:\n$gitstatus" + cd $dir + if [[ -d .git ]] + then + gitstatus="`git status -s | awk '{print $2}'`" + cd $ROOT + if [[ -n $gitstatus ]] + then + echo "- \033[0;31m$dir\033[0m:\n$gitstatus" + fi + else + # Recursion at it's finest + git_updated + cd $ROOT + fi fi - - cd .. - fi done }