tipos tag qué lista existen etiquetas crear comandos shell groovy

tag - Groovy ejecuta un comando de Git Shell



lista de comandos git (1)

Estoy intentando ejecutar el comando git shell en groovy. El primero se ejecuta bien pero el segundo devuelve el código de salida 128:

def workingDir = new File("path/to/dir") "git add .".execute(null, workingDir) def p = "git reset --hard".execute( null, workingDir ) p.text.eachLine {println it} println p.exitValue()

¿Cuál es el problema con este código?


El segundo proceso comienza antes de que termine el primero. Cuando se inicia el segundo proceso de git, git reconoce que ya hay un proceso de git operando en el mismo directorio que podría causar problemas, por lo que se equivoca. Si lee la secuencia de error del primer proceso, verá algo como esto:

fatal: Unable to create ''path/to/dir/.git/index.lock'': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.

Si espera que termine el primero antes de comenzar el segundo, debería funcionar. Algo como esto:

def workingDir = new File("path/to/dir/") def p = "git add .".execute(null, workingDir) p.waitFor() p = "git reset --hard".execute( null, workingDir ) p.text.eachLine {println it} println p.exitValue()