Last active
November 23, 2015 18:05
-
-
Save rbarros/61e270cbb4cab9726ac5 to your computer and use it in GitHub Desktop.
Script para criar arquivo .tar.gz com os arquivos dos commits informados.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Ramon Barros | |
# contato [a] ramon-barros.com | |
# v0.1.0 | |
#md5sum="md5sha1sum-0.9.5" | |
#"wget microbrew.org/tools/md5sha1sum/md5sha1sum-0.9.5.tar.gz" - automatizar instalação | |
md5="git-update.sh" | |
file_hash=$(date +"%m%d%Y%H%M%S") #"$(echo -n "$md5" | md5sum | awk '{ print $1 }' )" | |
tmp="tmp" | |
update="update_$file_hash" | |
echo "Script para compactar arquivos de um commit." | |
verlte() { | |
[ "$1" = "`echo -e "$1\n$2" | sort -n | head -n1`" ] | |
} | |
verlt() { | |
[ "$1" = "$2" ] && return 1 || verlte $1 $2 | |
} | |
# git version 1.8.5.2 (Apple Git-48) | |
check() { | |
return verlte git --version 1.0 && echo "yes" || echo "no" | |
} | |
if [ ! -d "$tmp" ]; then | |
mkdir $tmp | |
fi | |
if [ ! -d "$update" ]; then | |
mkdir "$tmp/$update" | |
fi | |
if [ check == "yes" ]; then | |
echo "Git não instalado ou version inferior a 1.0" | |
else | |
# Adiciona os filtros | |
read -p "Adicione os filtros:\n | |
Added (A)\n | |
Copied (C)\n | |
Deleted (D)\n | |
Modified (M)\n | |
Renamed (R)\n | |
Change (T)\n | |
Unmerged (U)\n | |
Unknown (X)\n | |
Broken (B)\n | |
Padrão (ACMRT):" filters | |
#if [ -z "$filters" ]; then | |
#echo "Os filtros são obrigatórios ." | |
#exit | |
#else | |
echo "Filtros: $filters" | |
#fi | |
# Hash do commit | |
read -p "Informe o(s) Hash(s) separado(s) por espaço: " hash | |
#if [ -z "$hash" ]; then | |
#echo "O Hash é obrigatório." | |
#exit | |
#else | |
echo "Hash: $hash" | |
#fi | |
git show --pretty=format: --name-only --diff-filter=$filters --summary $hash > "$tmp/$file_hash.txt" && | |
tar -T "$tmp/$file_hash.txt" -czvf "$tmp/$file_hash.tar.gz" && | |
rm -vf "$tmp/$file_hash.txt" && | |
tar -zxvf "$tmp/$file_hash.tar.gz" -C "$tmp/$update" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment