copybara: fixups

This commit is contained in:
Luke Granger-Brown 2024-04-26 18:01:33 +01:00
parent 587713944a
commit e6124408f2
9 changed files with 37 additions and 21 deletions

View file

@ -2,11 +2,24 @@
#
# 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 {
name = "copybara";
version = "master";
bazel = bazel_4;
bazel = hackedBazel;
src = ../../third_party/copybara;
@ -15,13 +28,17 @@ buildBazelPackage rec {
bazelTargets = [ "//java/com/google/copybara:copybara_deploy.jar" ];
removeRulesCC = false;
fetchConfigured = true;
dontAddBazelOpts = true;
bazelFlags = [
"--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 = {
sha256 = "sha256:1xahy74my2hr9763sv7ch3safj9mp5a78hg163gsnmqhfzvjh2cj";
sha256 = "sha256:0r3y4lxwf2kwdfvl5qqqr6kmc0gajsqr24fr7s3ygqjr22vn99qa";
preHook = ''
export COURSIER_CACHE="$(echo ''${NIX_BUILD_TOP}/tmp/coursier | sed -e 's,//,/,g')"
'';

View file

@ -168,7 +168,7 @@ public class CheckoutPath implements Comparable<CheckoutPath>, StarlarkValue {
LinkOption.NOFOLLOW_LINKS));
} catch (IOException 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?
}
}
@ -192,7 +192,7 @@ public class CheckoutPath implements Comparable<CheckoutPath>, StarlarkValue {
return create(checkoutDir.relativize(resolvedSymlink.getRegularFile()));
} catch (IOException 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);
}
}

View file

@ -463,7 +463,7 @@ public class Main {
generalOptions.getDirFactory().cleanupTempDirs();
// Only for profiling purposes, no need to use the console
logger.atInfo()
.log("Cleaned output directory:" + generalOptions.getDirFactory().getTmpRoot());
.log("Cleaned output directory: %s", generalOptions.getDirFactory().getTmpRoot());
return null;
});
}
@ -512,7 +512,7 @@ public class Main {
cause = cause.getCause();
}
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) {
@ -523,7 +523,7 @@ public class Main {
}
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 + ")");
}

View file

@ -295,7 +295,7 @@ public final class TransformWork implements SkylarkContext<TransformWork>, Starl
Files.createSymbolicLink(linkFullPath, relativized);
} catch (IOException e) {
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);
}
}

View file

@ -118,10 +118,10 @@ public final class BuildozerOptions implements Option {
.withInput(Joiner.on('\n').join(commands).getBytes(UTF_8))
.execute();
if (!output.getStdout().isEmpty()) {
logger.atInfo().log("buildozer stdout: " + output.getStdout());
logger.atInfo().log("buildozer stdout: %s", output.getStdout());
}
if (!output.getStderr().isEmpty()) {
logger.atInfo().log("buildozer stderr: " + output.getStderr());
logger.atInfo().log("buildozer stderr: %s", output.getStderr());
}
} catch (BadExitStatusWithOutputException e) {
// Don't print the output for common/known errors.

View file

@ -131,10 +131,10 @@ public class BuildifierFormat implements Transformation {
.withVerbose(generalOptions.isVerbose())
.execute();
if (!output.getStdout().isEmpty()) {
logger.atInfo().log("buildifier stdout: " + output.getStdout());
logger.atInfo().log("buildifier stdout: %s", output.getStdout());
}
if (!output.getStderr().isEmpty()) {
logger.atInfo().log("buildifier stderr: " + output.getStderr());
logger.atInfo().log("buildifier stderr: %s", output.getStderr());
}
} catch (BadExitStatusWithOutputException e) {
log(console, e.getOutput());

View file

@ -313,7 +313,7 @@ public class GitRepository {
return simpleCommand("describe", "--", rev.getSha1()).getStdout().trim();
} catch (RepoException e) {
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();
}
}

View file

@ -127,7 +127,7 @@ public class GitHubApiTransportImpl implements GitHubApiTransport {
String msg = String
.format("GitHub credentials not found in %s. Assuming the repository is public.",
storePath);
logger.atInfo().log(msg);
logger.atInfo().log("%s", msg);
console.info(msg);
return null;
}

View file

@ -185,10 +185,9 @@ public final class CommandRunner {
String startMsg = ShellUtils.prettyPrintArgv(Arrays.asList(cmd.getCommandLineElements()));
startMsg = startMsg.length() > MAX_COMMAND_LENGTH
? startMsg.substring(0, MAX_COMMAND_LENGTH) + "..." : startMsg;
String validStartMsg = "Executing [" + startMsg + "] in workdir [" + cmd.getWorkingDirectory() + "]";
logger.atInfo().log(validStartMsg);
logger.atInfo().log("Executing [%s] in workdir [%s]", startMsg, cmd.getWorkingDirectory());
if (verbose) {
System.err.println(validStartMsg);
System.err.println(String.format("Executing [%s] in workdir [%s]", startMsg, cmd.getWorkingDirectory()));
}
TerminationStatus exitStatus = null;
CombinedKillableObserver cmdMonitor =
@ -248,13 +247,13 @@ public final class CommandRunner {
"Command '%s' was killed after timeout. Execution time %s. %s",
commandName, formatDuration(stopwatch.elapsed()),
exitStatus != null ? exitStatus.toString() : "(No exit status)");
logger.atSevere().log(finishMsg);
logger.atSevere().log("%s", finishMsg);
} else {
finishMsg = String.format(
"Command '%s' finished in %s. %s",
commandName, formatDuration(stopwatch.elapsed()),
exitStatus != null ? exitStatus.toString() : "(No exit status)");
logger.atInfo().log(finishMsg);
logger.atInfo().log("%s", finishMsg);
}
if (verbose) {
System.err.println(finishMsg);
@ -320,7 +319,7 @@ private static class DefaultExecutor implements CommandExecutor {
}
int lines = 0;
for (String line : Splitter.on(System.lineSeparator()).split(string)) {
logger.at(level).log(prefix + line);
logger.at(level).log("%s%s", prefix, line);
lines++;
if (maxLogLines >= 0 && lines >= maxLogLines) {
logger.at(level).log("%s... truncated after %d line(s)", prefix, maxLogLines);