Guest User

Untitled

a guest
Feb 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # Uso: ./project-manual.sh
  4. # Crea un repositorio y realiza commits
  5. #
  6. # Uso: ./project-manual.sh -f
  7. # La opción -f fuerza a borrar el directorio
  8. # del repositorio si ya existe
  9. #
  10. set -e
  11.  
  12. # Nombre del repositorio
  13. repo="project-repo"
  14.  
  15.  
  16. # ==================================
  17. # = Funciones de ayuda =
  18. # ==================================
  19.  
  20. # En caso de fallo
  21. function die {
  22. echo "Error: $1"
  23. exit
  24. }
  25.  
  26. # Modifica el fichero pasado y hace un commit.
  27. # Uso: commit file
  28. # Uso: commit file "Mensaje del commit - opcional"
  29. function commit {
  30. file="$1"
  31. [[ -z $file ]] && die
  32. msg="Update $file"
  33. [[ -z $2 ]] || msg="$2"
  34.  
  35. # Modificar el fichero
  36. echo "`date "+TIME: %H:%M:%S"` - $RANDOM" >> $file
  37.  
  38. git add $file
  39.  
  40. # Hacer el commit mostrando sólo la primera línea que imprime
  41. git commit -m "$msg" | head -n1
  42. }
  43.  
  44.  
  45.  
  46. # ============================
  47. # = Preparación =
  48. # ============================
  49.  
  50. # Si nos pasan la opción -f forzamos a borrar el repositorio antes
  51. [[ "$1" == "-f" ]] && ( echo "Borrando $repo/"; rm -rf $repo )
  52.  
  53. # Salimos si el repo ya existe
  54. [[ -d $repo ]] && die "El repositorio ya existe"
  55.  
  56. # Crear e iniciar el repo
  57. echo "Creando $repo/"
  58. mkdir $repo
  59. cd $repo
  60.  
  61.  
  62. # ==============================
  63. # = Código GIT =
  64. # ==============================
  65. #
  66. # Algunas opciones de comandos git que se usan:
  67. #
  68. # export GIT_MERGE_AUTOEDIT=no
  69. # Hace que git flow no invoque el editor para los mensajes de las fusiones merge,
  70. # y use el mensaje por defecto. Equivalente a la opción --no-edit de git merge.
  71. #
  72. #
  73.  
  74. export GIT_MERGE_AUTOEDIT=no
  75.  
  76. echo "==== INIT repositorio"
  77. git flow init -d
  78. ## git flow ha creado un commit vacío con la rama master y develop
  79.  
  80. git lg
  81.  
  82. git checkout develop
  83. commit main.java
  84. commit main.java
  85.  
  86. git lg
  87.  
  88. echo
  89. echo "==== START feature/gui"
  90. git flow feature start gui
  91.  
  92. commit gui.java
  93. commit gui.java
  94.  
  95. echo
  96. echo "==== FINISH feature/gui"
  97. git flow feature finish gui
  98.  
  99. git lg
  100.  
  101. echo
  102. echo "==== START release/0.1"
  103. git flow release start 0.1
  104.  
  105. commit gui.java
  106.  
  107. git lg
  108.  
  109. echo
  110. echo "==== FINISH: release/0.1"
  111. git flow release finish -m "v0.1" 0.1
  112.  
  113. git lg
Add Comment
Please, Sign In to add comment