@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
public static void checkCommandFailed(@NotNull String cmdName, @NotNull ExecResult res, String... errorsLogLevel) throws VcsException {
- if (res.getExitCode() != 0 || res.getException() != null) {
- commandFailed(cmdName, res);
- }
- if (res.getStderr().length() > 0) {
- logMessage("Error output produced by: " + cmdName, errorsLogLevel);
- logMessage(res.getStderr().trim(), errorsLogLevel);
+ if ("info".equals(logLevel(errorsLogLevel)) && res.getExitCode() != 0 && res.getException() == null) {
+ logMessage("'" + cmdName + "' exit code: " + res.getExitCode() + ". It is expected behaviour.", "info");
+ } else {
+ if (res.getExitCode() != 0 || res.getException() != null) {
+ commandFailed(cmdName, res);
+ }
+ if (res.getStderr().length() > 0) {
+ logMessage("Error output produced by: " + cmdName, errorsLogLevel);
+ logMessage(res.getStderr().trim(), errorsLogLevel);
+ }
}
}
* @param level level to use
*/
private static void logMessage(String message, String... level) {
- String theLevel;
- if (level.length > 0) {
- theLevel = level[0];
- } else {
- theLevel = "warn";
- }
+ final String theLevel = logLevel(level);
if (theLevel.equals("warn")) {
Loggers.VCS.warn(message);
} else if (theLevel.equals("debug")) {
Loggers.VCS.debug(message);
+ } else if (theLevel.equals("info")) {
+ Loggers.VCS.info(message);
}
}
+ private static String logLevel(String... level) {
+ return level.length > 0 ? level[0] : "warn";
+ }
+
public static ExecResult runCommand(@NotNull GitCommandLine cli, final String... errorsLogLevel) throws VcsException {
return runCommand(cli, DEFAULT_COMMAND_TIMEOUT_SEC, errorsLogLevel);
}
@NotNull
public String call() throws VcsException {
+ return callWithLevel();
+ }
+
+ @NotNull
+ public String callWithIgnoreExitCode() throws VcsException {
+ return callWithLevel("info");
+ }
+
+ private String callWithLevel(String... logLevel) throws VcsException {
GitCommandLine cmd = getCmd();
cmd.addParameters("config", myName);
- ExecResult r = CommandUtil.runCommand(cmd);
+ ExecResult r = CommandUtil.runCommand(cmd, logLevel);
CommandUtil.failIfNotEmptyStdErr(cmd, r);
return r.getStdout().trim();
}
private void deleteSslOption(@NotNull final GitFacade gitFacade) {
try {
- final String previous = gitFacade.getConfig().setPropertyName("http.sslCAInfo").call();
+ final String previous = gitFacade.getConfig().setPropertyName("http.sslCAInfo").callWithIgnoreExitCode();
if (!StringUtil.isEmptyOrSpaces(previous)) {
/* do not need custom certificate then remove corresponding options if exists */
gitFacade.setConfig().setPropertyName("http.sslCAInfo").unSet().call();
try {
gitFacade.setConfig().setPropertyName("http.sslCAInfo").setValue(path).call();
} catch (Exception e) {
- LOG.error("Error while setting sslCAInfo git option");
+ LOG.error("Error while setting sslCAInfo git option", e);
}
}