@@ -121,10 +121,10 @@ private String getBranchForHead(File canonical) throws GitCommitIdExecutionExcep
121121 if (noSymbolicRef || noSuchRef ) {
122122 branch = getCommitId ();
123123 } else {
124- throw new RuntimeException (e );
124+ throw new GitCommitIdExecutionException (e );
125125 }
126126 } else {
127- throw new RuntimeException (e );
127+ throw new GitCommitIdExecutionException (e );
128128 }
129129 }
130130 return branch ;
@@ -343,27 +343,27 @@ private boolean tryCheckEmptyRunGitCommand(File directory, long nativeGitTimeout
343343 String command = String .format ("%s %s" , exec , gitCommand );
344344
345345 return getRunner ().runEmpty (directory , nativeGitTimeoutInMs , command );
346- } catch (IOException ex ) {
346+ } catch (IOException | GitCommitIdExecutionException ex ) {
347347 log .error ("Failed to run git command" , ex );
348348 // Error means "non-empty"
349349 return false ;
350350 // do nothing...
351351 }
352352 }
353353
354- private String runQuietGitCommand (File directory , long nativeGitTimeoutInMs , String gitCommand ) {
354+ private String runQuietGitCommand (File directory , long nativeGitTimeoutInMs , String gitCommand ) throws GitCommitIdExecutionException {
355355 final String env = System .getenv ("GIT_PATH" );
356356 final String exec = env == null ? "git" : env ;
357357 final String command = String .format ("%s %s" , exec , gitCommand );
358358
359359 try {
360360 return getRunner ().run (directory , nativeGitTimeoutInMs , command .trim ()).trim ();
361361 } catch (IOException e ) {
362- throw new RuntimeException (e );
362+ throw new GitCommitIdExecutionException (e );
363363 }
364364 }
365365
366- private String runGitCommand (File directory , long nativeGitTimeoutInMs , String gitCommand ) throws NativeCommandException {
366+ private String runGitCommand (File directory , long nativeGitTimeoutInMs , String gitCommand ) throws GitCommitIdExecutionException {
367367 final String env = System .getenv ("GIT_PATH" );
368368 String exec = env == null ? "git" : env ;
369369 final String command = String .format ("%s %s" , exec , gitCommand );
@@ -373,7 +373,7 @@ private String runGitCommand(File directory, long nativeGitTimeoutInMs, String g
373373 } catch (NativeCommandException e ) {
374374 throw e ;
375375 } catch (IOException e ) {
376- throw new RuntimeException (e );
376+ throw new GitCommitIdExecutionException (e );
377377 }
378378 }
379379
@@ -393,7 +393,7 @@ public interface ProcessRunner {
393393 * @return the output obtained from stdout by running the command
394394 * @throws IOException the command execution failed
395395 */
396- String run (File directory , long nativeGitTimeoutInMs , String command ) throws IOException ;
396+ String run (File directory , long nativeGitTimeoutInMs , String command ) throws IOException , GitCommitIdExecutionException ;
397397
398398 /** Run a command and return false if it contains at least one output line
399399 *
@@ -403,10 +403,10 @@ public interface ProcessRunner {
403403 * @return false if the output of the command contains at least one line on stdout, true otherwise
404404 * @throws IOException the command execution failed
405405 */
406- boolean runEmpty (File directory , long nativeGitTimeoutInMs , String command ) throws IOException ;
406+ boolean runEmpty (File directory , long nativeGitTimeoutInMs , String command ) throws IOException , GitCommitIdExecutionException ;
407407 }
408408
409- public static class NativeCommandException extends IOException {
409+ public static class NativeCommandException extends GitCommitIdExecutionException {
410410 private static final long serialVersionUID = 3511033422542257748L ;
411411 private final int exitCode ;
412412 private final String command ;
@@ -455,7 +455,7 @@ public String getMessage() {
455455
456456 protected static class JavaProcessRunner implements ProcessRunner {
457457 @ Override
458- public String run (File directory , long nativeGitTimeoutInMs , String command ) throws IOException {
458+ public String run (File directory , long nativeGitTimeoutInMs , String command ) throws IOException , GitCommitIdExecutionException {
459459 String output = "" ;
460460 try {
461461 final StringBuilder commandResult = new StringBuilder ();
@@ -477,7 +477,7 @@ public String run(File directory, long nativeGitTimeoutInMs, String command) thr
477477 }
478478
479479 @ Override
480- public boolean runEmpty (File directory , long nativeGitTimeoutInMs , String command ) throws IOException {
480+ public boolean runEmpty (File directory , long nativeGitTimeoutInMs , String command ) throws IOException , GitCommitIdExecutionException {
481481 final AtomicBoolean empty = new AtomicBoolean (true );
482482
483483 try {
@@ -499,7 +499,7 @@ private void runProcess(
499499 File directory ,
500500 long nativeGitTimeoutInMs ,
501501 String command ,
502- final Function <String , Boolean > stdoutConsumer ) throws InterruptedException , IOException {
502+ final Function <String , Boolean > stdoutConsumer ) throws InterruptedException , IOException , GitCommitIdExecutionException {
503503
504504 final ProcessBuilder builder = new ProcessBuilder (command .split ("\\ s" ));
505505 final Process proc = builder .directory (directory ).start ();
0 commit comments