Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #
- # Uso: ./project-manual.sh
- # Crea un repositorio y realiza commits
- #
- # Uso: ./project-manual.sh -f
- # La opción -f fuerza a borrar el directorio
- # del repositorio si ya existe
- #
- set -e
- # Nombre del repositorio
- repo="project-repo"
- # ==================================
- # = Funciones de ayuda =
- # ==================================
- # En caso de fallo
- function die {
- echo "Error: $1"
- exit
- }
- # Modifica el fichero pasado y hace un commit.
- # Uso: commit file
- # Uso: commit file "Mensaje del commit - opcional"
- function commit {
- file="$1"
- [[ -z $file ]] && die
- msg="Update $file"
- [[ -z $2 ]] || msg="$2"
- # Modificar el fichero
- echo "`date "+TIME: %H:%M:%S"` - $RANDOM" >> $file
- git add $file
- # Hacer el commit mostrando sólo la primera línea que imprime
- git commit -m "$msg" | head -n1
- }
- # ============================
- # = Preparación =
- # ============================
- # Si nos pasan la opción -f forzamos a borrar el repositorio antes
- [[ "$1" == "-f" ]] && ( echo "Borrando $repo/"; rm -rf $repo )
- # Salimos si el repo ya existe
- [[ -d $repo ]] && die "El repositorio ya existe"
- # Crear e iniciar el repo
- echo "Creando $repo/"
- mkdir $repo
- cd $repo
- # ==============================
- # = Código GIT =
- # ==============================
- #
- # Algunas opciones de comandos git que se usan:
- #
- # export GIT_MERGE_AUTOEDIT=no
- # Hace que git flow no invoque el editor para los mensajes de las fusiones merge,
- # y use el mensaje por defecto. Equivalente a la opción --no-edit de git merge.
- #
- #
- export GIT_MERGE_AUTOEDIT=no
- echo "==== INIT repositorio"
- git flow init -d
- ## git flow ha creado un commit vacío con la rama master y develop
- git lg
- git checkout develop
- commit main.java
- commit main.java
- git lg
- echo
- echo "==== START feature/gui"
- git flow feature start gui
- commit gui.java
- commit gui.java
- echo
- echo "==== FINISH feature/gui"
- git flow feature finish gui
- git lg
- echo
- echo "==== START release/0.1"
- git flow release start 0.1
- commit gui.java
- git lg
- echo
- echo "==== FINISH: release/0.1"
- git flow release finish -m "v0.1" 0.1
- git lg
Add Comment
Please, Sign In to add comment