Skip to content

Commit

Permalink
Update Git tools
Browse files Browse the repository at this point in the history
  • Loading branch information
victoriadrake committed Oct 9, 2021
1 parent 9cbb4d8 commit 8fbcb8b
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .git-rundown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

# Check system language and add strings
case $LANG in
es_ES.UTF-8)
check_modif="modificado"
message_modif="modificado"
check_untr="seguimiento"
message_untr="archivos sin seguimiento"
check_unpush="adelantada"
message_unpush="falta hacer push"
clean="nada a hacer commit"
no_git="no es un repositorio de git"
;;
*)
check_modif="modified"
message_modif="modified"
check_untr="untracked"
message_untr="untracked"
check_unpush="ahead"
message_unpush="unpushed"
clean="nothing to commit"
no_git="not a git repository"
;;
esac

dir="$1"

# No directory has been provided, use current
if [[ -z "$dir" ]]
then
dir="`pwd`"
fi

# Make sure directory ends with "/"
if [[ $dir != */ ]]
then
dir="$dir/*"
else
dir="$dir*"
fi

# Loop all sub-directories
for f in $dir
do
# Only interested in directories
[[ -d "${f}" ]] || continue

# Check if directory is a git repository
if [[ -d "$f/.git" ]]
then
echo -en "\033[0;35m"
echo "${f}"
echo -en "\033[0m"

mod=0
cd $f

# Print branch
s=$(git status | head -n1)
echo -en "\033[0;36m${s:10}\033[0m "

# Check for modified files
if [[ $(git status | grep "$check_modif" -c) -ne 0 ]]
then
mod=1
echo -en "\033[0;93m$message_modif\033[0m "
fi

# Check for untracked files
if [[ $(git status | grep "$check_untr" -c) -ne 0 ]]
then
mod=1
echo -en "\033[0;91m$message_untr\033[0m "
fi

# Check for unpushed changes
if [[ $(git status | grep "$check_unpush" -c) -ne 0 ]]
then
mod=1
echo -en "\033[0;92m$message_unpush\033[0m "
fi


# Check if everything is peachy keen
if [[ $mod -eq 0 ]]
then
echo -en "$clean"
fi

echo -e " "

cd ../
else
# Not a git repository

echo -en "\033[0;37m"
echo "${f}"
echo "$no_git"
echo -en "\033[0m"
fi
echo
done
22 changes: 22 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[alias]
# Adapted from https://blog.jez.io/cli-code-review/
# List files which have changed since BASE
# Set BASE in shell configuration or before the command
files = !git diff --name-only $(git merge-base HEAD \"$BASE\")

# With stat for interactive use
stat = !git diff --stat $(git merge-base HEAD \"$BASE\")

# Put heatmap on your path:
# https://github.com/jez/git-heatmap/blob/master/git-heatmap
heatmap = git-heatmap

# Open all files changed since BASE in Vim tabs
# Then, run fugitive's :Gdiff in each tab, and finally
# tell vim-gitgutter to show +/- for changes since BASE
review = !vim -p $(git files) +\"tabdo Gdiff $BASE\" +\"let g:gitgutter_diff_base = '$BASE'\"

# Same as the above, except specify names of files as arguments,
# instead of opening all files:
# git reviewone foo.js bar.js
reviewone = !vim -p +\"tabdo Gdiff $BASE\" +\"let g:gitgutter_diff_base = '$BASE'\"
2 changes: 2 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" use plugin on GitHub repo
Plugin 'airblade/vim-gitgutter'
Plugin 'jez/vim-colors-solarized'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Expand Down

0 comments on commit 8fbcb8b

Please sign in to comment.