copybara: fixups
This commit is contained in:
parent
587713944a
commit
e6124408f2
9 changed files with 37 additions and 21 deletions
|
@ -2,11 +2,24 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
{ buildBazelPackage, openjdk11_headless, bazel_4, git, mercurial, makeWrapper, fetchFromGitHub }:
|
{ buildBazelPackage, buildFHSUserEnv, openjdk11_headless, bazel, git, mercurial, makeWrapper, fetchFromGitHub }:
|
||||||
|
let
|
||||||
|
hackedBazelTop = buildFHSUserEnv {
|
||||||
|
name = "bazel";
|
||||||
|
targetPkgs = pkgs: [
|
||||||
|
(bazel.override { enableNixHacks = true; })
|
||||||
|
openjdk11_headless
|
||||||
|
git
|
||||||
|
mercurial
|
||||||
|
];
|
||||||
|
runScript = "/bin/bazel";
|
||||||
|
};
|
||||||
|
hackedBazel = hackedBazelTop // { override = x: hackedBazelTop; };
|
||||||
|
in
|
||||||
buildBazelPackage rec {
|
buildBazelPackage rec {
|
||||||
name = "copybara";
|
name = "copybara";
|
||||||
version = "master";
|
version = "master";
|
||||||
bazel = bazel_4;
|
bazel = hackedBazel;
|
||||||
|
|
||||||
src = ../../third_party/copybara;
|
src = ../../third_party/copybara;
|
||||||
|
|
||||||
|
@ -15,13 +28,17 @@ buildBazelPackage rec {
|
||||||
bazelTargets = [ "//java/com/google/copybara:copybara_deploy.jar" ];
|
bazelTargets = [ "//java/com/google/copybara:copybara_deploy.jar" ];
|
||||||
removeRulesCC = false;
|
removeRulesCC = false;
|
||||||
fetchConfigured = true;
|
fetchConfigured = true;
|
||||||
|
dontAddBazelOpts = true;
|
||||||
bazelFlags = [
|
bazelFlags = [
|
||||||
"--javabase=@local_jdk//:jdk"
|
"--javabase=@local_jdk//:jdk"
|
||||||
"--host_javabase=@local_jdk//:jdk"
|
"--host_javabase=@local_jdk//:jdk"
|
||||||
|
"--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
|
||||||
|
"--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8"
|
||||||
|
"--define=EXECUTOR=remote"
|
||||||
];
|
];
|
||||||
|
|
||||||
fetchAttrs = {
|
fetchAttrs = {
|
||||||
sha256 = "sha256:1xahy74my2hr9763sv7ch3safj9mp5a78hg163gsnmqhfzvjh2cj";
|
sha256 = "sha256:0r3y4lxwf2kwdfvl5qqqr6kmc0gajsqr24fr7s3ygqjr22vn99qa";
|
||||||
preHook = ''
|
preHook = ''
|
||||||
export COURSIER_CACHE="$(echo ''${NIX_BUILD_TOP}/tmp/coursier | sed -e 's,//,/,g')"
|
export COURSIER_CACHE="$(echo ''${NIX_BUILD_TOP}/tmp/coursier | sed -e 's,//,/,g')"
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class CheckoutPath implements Comparable<CheckoutPath>, StarlarkValue {
|
||||||
LinkOption.NOFOLLOW_LINKS));
|
LinkOption.NOFOLLOW_LINKS));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String msg = "Error getting attributes for " + path + ":" + e;
|
String msg = "Error getting attributes for " + path + ":" + e;
|
||||||
logger.atSevere().withCause(e).log(msg);
|
logger.atSevere().withCause(e).log("%s", msg);
|
||||||
throw Starlark.errorf("%s", msg); // or IOException?
|
throw Starlark.errorf("%s", msg); // or IOException?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class CheckoutPath implements Comparable<CheckoutPath>, StarlarkValue {
|
||||||
return create(checkoutDir.relativize(resolvedSymlink.getRegularFile()));
|
return create(checkoutDir.relativize(resolvedSymlink.getRegularFile()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String msg = String.format("Cannot resolve symlink %s: %s", path, e);
|
String msg = String.format("Cannot resolve symlink %s: %s", path, e);
|
||||||
logger.atSevere().withCause(e).log(msg);
|
logger.atSevere().withCause(e).log("%s", msg);
|
||||||
throw Starlark.errorf("%s", msg);
|
throw Starlark.errorf("%s", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,7 +463,7 @@ public class Main {
|
||||||
generalOptions.getDirFactory().cleanupTempDirs();
|
generalOptions.getDirFactory().cleanupTempDirs();
|
||||||
// Only for profiling purposes, no need to use the console
|
// Only for profiling purposes, no need to use the console
|
||||||
logger.atInfo()
|
logger.atInfo()
|
||||||
.log("Cleaned output directory:" + generalOptions.getDirFactory().getTmpRoot());
|
.log("Cleaned output directory: %s", generalOptions.getDirFactory().getTmpRoot());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ public class Main {
|
||||||
cause = cause.getCause();
|
cause = cause.getCause();
|
||||||
}
|
}
|
||||||
console.error(error.toString());
|
console.error(error.toString());
|
||||||
logger.at(level).withCause(e).log(formatLogError(e.getMessage(), args));
|
logger.at(level).withCause(e).log("%s", formatLogError(e.getMessage(), args));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String printException(Throwable t) {
|
private String printException(Throwable t) {
|
||||||
|
@ -523,7 +523,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUnexpectedError(Console console, String msg, String[] args, Throwable e) {
|
private void handleUnexpectedError(Console console, String msg, String[] args, Throwable e) {
|
||||||
logger.atSevere().withCause(e).log(formatLogError(msg, args));
|
logger.atSevere().withCause(e).log("%s", formatLogError(msg, args));
|
||||||
console.error(msg + " (" + e + ")");
|
console.error(msg + " (" + e + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ public final class TransformWork implements SkylarkContext<TransformWork>, Starl
|
||||||
Files.createSymbolicLink(linkFullPath, relativized);
|
Files.createSymbolicLink(linkFullPath, relativized);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
String msg = "Cannot create symlink: " + e.getMessage();
|
String msg = "Cannot create symlink: " + e.getMessage();
|
||||||
logger.atSevere().withCause(e).log(msg);
|
logger.atSevere().withCause(e).log("%s", msg);
|
||||||
throw Starlark.errorf("%s", msg);
|
throw Starlark.errorf("%s", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,10 +118,10 @@ public final class BuildozerOptions implements Option {
|
||||||
.withInput(Joiner.on('\n').join(commands).getBytes(UTF_8))
|
.withInput(Joiner.on('\n').join(commands).getBytes(UTF_8))
|
||||||
.execute();
|
.execute();
|
||||||
if (!output.getStdout().isEmpty()) {
|
if (!output.getStdout().isEmpty()) {
|
||||||
logger.atInfo().log("buildozer stdout: " + output.getStdout());
|
logger.atInfo().log("buildozer stdout: %s", output.getStdout());
|
||||||
}
|
}
|
||||||
if (!output.getStderr().isEmpty()) {
|
if (!output.getStderr().isEmpty()) {
|
||||||
logger.atInfo().log("buildozer stderr: " + output.getStderr());
|
logger.atInfo().log("buildozer stderr: %s", output.getStderr());
|
||||||
}
|
}
|
||||||
} catch (BadExitStatusWithOutputException e) {
|
} catch (BadExitStatusWithOutputException e) {
|
||||||
// Don't print the output for common/known errors.
|
// Don't print the output for common/known errors.
|
||||||
|
|
|
@ -131,10 +131,10 @@ public class BuildifierFormat implements Transformation {
|
||||||
.withVerbose(generalOptions.isVerbose())
|
.withVerbose(generalOptions.isVerbose())
|
||||||
.execute();
|
.execute();
|
||||||
if (!output.getStdout().isEmpty()) {
|
if (!output.getStdout().isEmpty()) {
|
||||||
logger.atInfo().log("buildifier stdout: " + output.getStdout());
|
logger.atInfo().log("buildifier stdout: %s", output.getStdout());
|
||||||
}
|
}
|
||||||
if (!output.getStderr().isEmpty()) {
|
if (!output.getStderr().isEmpty()) {
|
||||||
logger.atInfo().log("buildifier stderr: " + output.getStderr());
|
logger.atInfo().log("buildifier stderr: %s", output.getStderr());
|
||||||
}
|
}
|
||||||
} catch (BadExitStatusWithOutputException e) {
|
} catch (BadExitStatusWithOutputException e) {
|
||||||
log(console, e.getOutput());
|
log(console, e.getOutput());
|
||||||
|
|
|
@ -313,7 +313,7 @@ public class GitRepository {
|
||||||
return simpleCommand("describe", "--", rev.getSha1()).getStdout().trim();
|
return simpleCommand("describe", "--", rev.getSha1()).getStdout().trim();
|
||||||
} catch (RepoException e) {
|
} catch (RepoException e) {
|
||||||
logger.atWarning()
|
logger.atWarning()
|
||||||
.withCause(e).log("Cannot get describe version for commit " + rev.getSha1());
|
.withCause(e).log("Cannot get describe version for commit %s", rev.getSha1());
|
||||||
return simpleCommand("describe", "--always", "--", rev.getSha1()).getStdout().trim();
|
return simpleCommand("describe", "--always", "--", rev.getSha1()).getStdout().trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class GitHubApiTransportImpl implements GitHubApiTransport {
|
||||||
String msg = String
|
String msg = String
|
||||||
.format("GitHub credentials not found in %s. Assuming the repository is public.",
|
.format("GitHub credentials not found in %s. Assuming the repository is public.",
|
||||||
storePath);
|
storePath);
|
||||||
logger.atInfo().log(msg);
|
logger.atInfo().log("%s", msg);
|
||||||
console.info(msg);
|
console.info(msg);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,10 +185,9 @@ public final class CommandRunner {
|
||||||
String startMsg = ShellUtils.prettyPrintArgv(Arrays.asList(cmd.getCommandLineElements()));
|
String startMsg = ShellUtils.prettyPrintArgv(Arrays.asList(cmd.getCommandLineElements()));
|
||||||
startMsg = startMsg.length() > MAX_COMMAND_LENGTH
|
startMsg = startMsg.length() > MAX_COMMAND_LENGTH
|
||||||
? startMsg.substring(0, MAX_COMMAND_LENGTH) + "..." : startMsg;
|
? startMsg.substring(0, MAX_COMMAND_LENGTH) + "..." : startMsg;
|
||||||
String validStartMsg = "Executing [" + startMsg + "] in workdir [" + cmd.getWorkingDirectory() + "]";
|
logger.atInfo().log("Executing [%s] in workdir [%s]", startMsg, cmd.getWorkingDirectory());
|
||||||
logger.atInfo().log(validStartMsg);
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
System.err.println(validStartMsg);
|
System.err.println(String.format("Executing [%s] in workdir [%s]", startMsg, cmd.getWorkingDirectory()));
|
||||||
}
|
}
|
||||||
TerminationStatus exitStatus = null;
|
TerminationStatus exitStatus = null;
|
||||||
CombinedKillableObserver cmdMonitor =
|
CombinedKillableObserver cmdMonitor =
|
||||||
|
@ -248,13 +247,13 @@ public final class CommandRunner {
|
||||||
"Command '%s' was killed after timeout. Execution time %s. %s",
|
"Command '%s' was killed after timeout. Execution time %s. %s",
|
||||||
commandName, formatDuration(stopwatch.elapsed()),
|
commandName, formatDuration(stopwatch.elapsed()),
|
||||||
exitStatus != null ? exitStatus.toString() : "(No exit status)");
|
exitStatus != null ? exitStatus.toString() : "(No exit status)");
|
||||||
logger.atSevere().log(finishMsg);
|
logger.atSevere().log("%s", finishMsg);
|
||||||
} else {
|
} else {
|
||||||
finishMsg = String.format(
|
finishMsg = String.format(
|
||||||
"Command '%s' finished in %s. %s",
|
"Command '%s' finished in %s. %s",
|
||||||
commandName, formatDuration(stopwatch.elapsed()),
|
commandName, formatDuration(stopwatch.elapsed()),
|
||||||
exitStatus != null ? exitStatus.toString() : "(No exit status)");
|
exitStatus != null ? exitStatus.toString() : "(No exit status)");
|
||||||
logger.atInfo().log(finishMsg);
|
logger.atInfo().log("%s", finishMsg);
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
System.err.println(finishMsg);
|
System.err.println(finishMsg);
|
||||||
|
@ -320,7 +319,7 @@ private static class DefaultExecutor implements CommandExecutor {
|
||||||
}
|
}
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
for (String line : Splitter.on(System.lineSeparator()).split(string)) {
|
for (String line : Splitter.on(System.lineSeparator()).split(string)) {
|
||||||
logger.at(level).log(prefix + line);
|
logger.at(level).log("%s%s", prefix, line);
|
||||||
lines++;
|
lines++;
|
||||||
if (maxLogLines >= 0 && lines >= maxLogLines) {
|
if (maxLogLines >= 0 && lines >= maxLogLines) {
|
||||||
logger.at(level).log("%s... truncated after %d line(s)", prefix, maxLogLines);
|
logger.at(level).log("%s... truncated after %d line(s)", prefix, maxLogLines);
|
||||||
|
|
Loading…
Reference in a new issue