ajout du super script pour pas push ses headers JUST DO IT
This commit is contained in:
parent
7b6f848d00
commit
15870d6a89
1 changed files with 82 additions and 0 deletions
82
42sh/scriptheader.sh
Executable file
82
42sh/scriptheader.sh
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
#!/bin/sh
|
||||
|
||||
function elem_in_array()
|
||||
{
|
||||
for cur in $2
|
||||
do
|
||||
if [ "$1" == "$cur" ]
|
||||
then
|
||||
echo "1"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
echo "0"
|
||||
return 0
|
||||
}
|
||||
|
||||
function array_in_array()
|
||||
{
|
||||
for cur in $1
|
||||
do
|
||||
match=$(elem_in_array "$cur" "$2")
|
||||
if [ "$match" -ne 1 ]
|
||||
then
|
||||
echo "0"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "1"
|
||||
return 1
|
||||
}
|
||||
|
||||
word=$(git status -s | sed 's/.* //')
|
||||
red="\033[38;5;1m"
|
||||
gre="\033[38;5;2m"
|
||||
cya="\033[38;5;6m"
|
||||
res="\033[0m"
|
||||
|
||||
for i in $word
|
||||
do
|
||||
if [ -e $i ]
|
||||
then
|
||||
if [ -f $i ]
|
||||
then
|
||||
diff=$(git diff -U0 --exit-code --color $i)
|
||||
if [ "$?" -eq 1 ]
|
||||
then
|
||||
nb_lines=$(echo "$diff" | wc -l)
|
||||
if [ "$nb_lines" -eq 7 ]
|
||||
then
|
||||
match=$(array_in_array "-9 +9 Updated: by ### ########.fr" "$diff")
|
||||
if [ $match -eq 1 ]
|
||||
then
|
||||
echo "\n$cya CHANGES on $i :$res"
|
||||
echo "$diff"
|
||||
echo "$cya Are you sure?$res"
|
||||
read -r -p " [y/N]" response
|
||||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
|
||||
then
|
||||
i_tmp=$(echo $i | sed 's/\//_/g')
|
||||
cp $i "$HOME/Documents/.$i_tmp.back"
|
||||
git checkout $i
|
||||
echo "$gre D - O - N - E $res"
|
||||
echo "$cya $i was checked out. A copy still exist in $HOME/Documents/.$i_tmp.back$res\n"
|
||||
else
|
||||
echo "$cya Nothing done for $i$res\n"
|
||||
fi
|
||||
else
|
||||
echo "$gre$i is not concerned (diff on the good lines)$res"
|
||||
fi
|
||||
else
|
||||
echo "$gre$i is not concerned (diff is too big)$res"
|
||||
fi
|
||||
else
|
||||
echo "$gre$i is not concerned (diff is null)$res"
|
||||
fi
|
||||
else
|
||||
echo "$red$i is not a regular file$res"
|
||||
fi
|
||||
else
|
||||
echo "$red$i doesn't exist$res"
|
||||
fi
|
||||
done
|
||||
Loading…
Reference in a new issue