private boolean executeGitHasUncommitted ( ) throws MojoFailureException , CommandLineException { boolean uncommited = false ; // 1 if there were differences and 0 means no differences // git diff --no-ext-diff --ignore-submodules --quiet --exit-code final CommandResult diffCommandResult = executeGitCommandExitCode ( "diff" , "--no-ext-diff" , "--ignore-submodules" , "--quiet" , "--exit-code" ) ; String error = null ; if ( diffCommandResult . getExitCode ( ) == SUCCESS_EXIT_CODE ) { // git diff-index --cached --quiet --ignore-submodules HEAD -- final CommandResult diffIndexCommandResult = executeGitCommandExitCode ( "diff-index" , "--cached" , "--quiet" , "--ignore-submodules" , "HEAD" , "--" ) ; if ( diffIndexCommandResult . getExitCode ( ) != SUCCESS_EXIT_CODE ) { error = diffIndexCommandResult . getError ( ) ; uncommited = true ; } } else { error = diffCommandResult . getError ( ) ; uncommited = true ; } if ( StringUtils . isNotBlank ( error ) ) { throw new MojoFailureException ( error ) ; } return uncommited ; }
Executes git commands to check for uncommitted changes .