Created
February 21, 2012 15:35
-
-
Save trico/1877054 to your computer and use it in GitHub Desktop.
Alias y comandos sh
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
# Alias node | |
alias node="D:\node.exe" | |
# Alias python | |
alias python="C:/Python27/python.exe" | |
# Alias a la carpeta de programas python | |
alias fl="c:/Users/eponce/python" | |
# Comandos chachi | |
alias addtodos="git add ." | |
alias amendtodos="git commit --amend" | |
alias ultim="git archive --format=zip HEAD `git diff HEAD^ HEAD --name-only` > update.zip" | |
alias ultim_nodl="git archive --format=zip HEAD `git diff HEAD^ HEAD --name-only --diff-filter=ACMRTUXB` > update.zip" | |
# Proyectos | |
alias danonino="cd d:/wamp/www/danonino" | |
alias alpiste="cd d:/wamp/www/alpiste" | |
# Deploy entre commits y tags | |
# deploy <id1> <id2> <nombre del deploy (opcional) <unzip (opcional) te descomprime el zip > > | |
# Ejemplos: | |
# deploy 0.1 0.3 | |
# deploy 0.1 HEAD update | |
# deploy HEAD^ HEAD (último deploy) | |
# deploy 5b129b4 ce69bef | |
# Alias log | |
alias log="git log --oneline --graph --decorate" | |
# Alias ptr.py | |
alias ptr="C:/Python27/python.exe c:/Users/eponce/python/ptr.py" | |
deploy(){ | |
if [ $3 ]; then | |
name=$3 | |
else | |
name="deploy_parcial.zip" | |
fi | |
if [[ -n $1 ]] && [[ -n $2 ]]; then | |
echo | |
git log $1..$2 --oneline --graph --decorate | |
echo | |
git archive --format=zip HEAD `git diff $1 $2 --name-only --diff-filter=ACMRTUXB` > $name | |
echo -e "\e[00;32mDeploy generado desde\e[00m \e[00;36m$1\e[00m \e[00;32ma\e[00m \e[00;36m$2\e[00m \e[00;32mcon el nombre\e[00m \e[00;36m$name\e[00m"; | |
if [[ $4 == 'unzip' ]]; then | |
ptr $name | |
fi | |
else | |
echo | |
echo -e '\e[00;31m Error: debes especificar los tags: deploy <id1> <id2> <nombre del deploy (opcional)> \e[00m'; | |
fi | |
} |
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
# Alias log | |
alias log="git log --oneline --graph --decorate" | |
deploy(){ | |
if [ $3 ]; then | |
name=$3 | |
else | |
name="deploy_parcial.zip" | |
fi | |
if [[ -n $1 ]] && [[ -n $2 ]]; then | |
echo | |
git log $1..$2 --oneline --graph --decorate | |
echo | |
git archive --format=zip HEAD `git diff $1 $2 --name-only --diff-filter=ACMRTUXB` > $name | |
echo -e "\e[00;32mDeploy generado desde\e[00m \e[00;36m$1\e[00m \e[00;32ma\e[00m \e[00;36m$2\e[00m \e[00;32mcon el nombre\e[00m \e[00;36m$name\e[00m"; | |
if [[ $4 == 'unzip' ]]; then | |
git archive --format=tar HEAD `git diff $1 $2 --name-only --diff-filter=ACMRTUXB` | (cd ./update_deploy/ && tar xf -) | |
echo 'unzip completado en la carpeta update_deploy' | |
fi | |
else | |
echo | |
echo -e '\e[00;31m Error: debes especificar los tags: deploy <id1> <id2> <nombre del deploy (opcional)> \e[00m'; | |
fi | |
} |
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
import zipfile | |
import sys | |
import shutil | |
nombre_fichero = sys.argv[1] | |
carpeta = 'update_deploy' | |
def main(): | |
if(iszip()): | |
unzip() | |
else: | |
print '' | |
print 'no es un zip!' | |
def iszip(): | |
return zipfile.is_zipfile(nombre_fichero) | |
def unzip(): | |
try: | |
shutil.rmtree(carpeta) | |
with zipfile.ZipFile(nombre_fichero) as myzip: | |
myzip.extractall(carpeta) | |
print '' | |
print 'Deploy extraido correctamente en la carpeta ' + carpeta | |
except Exception: | |
print '' | |
print 'NO EXISTE LA CARPETA ' + carpeta | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment