diff --git a/constants.bzl b/constants.bzl index 39263c4..e7e7e64 100644 --- a/constants.bzl +++ b/constants.bzl @@ -2,8 +2,5 @@ Various constants used to build bazel-diff """ -DEFAULT_JVM_EXTERNAL_TAG = "3.3" - -RULES_JVM_EXTERNAL_SHA = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab" - -BUILD_PROTO_MESSAGE_SHA = "50b79faec3c4154bed274371de5678b221165e38ab59c6167cc94b922d9d9152" +DEFAULT_JVM_EXTERNAL_TAG = "4.2" +RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca" diff --git a/repositories.bzl b/repositories.bzl index 7b77f59..6e9ed0b 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -15,20 +15,19 @@ def bazel_diff_dependencies(rules_jvm_external_tag=DEFAULT_JVM_EXTERNAL_TAG, http_archive, name = "bazel_skylib", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", ], - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", + sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", ) _maybe( http_archive, name = "rules_proto", - sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208", - strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313", + sha256 = "c22cfcb3f22a0ae2e684801ea8dfed070ba5bed25e73f73580564f250475e72d", + strip_prefix = "rules_proto-4.0.0-3.19.2", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.19.2.tar.gz", ], ) diff --git a/src/main/java/com/bazel_diff/GitClient.java b/src/main/java/com/bazel_diff/GitClient.java deleted file mode 100644 index 7518ffe..0000000 --- a/src/main/java/com/bazel_diff/GitClient.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.bazel_diff; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.file.Path; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -interface GitClient { - File getRepoRootDirectory() throws IOException, InterruptedException, GitClientException; - Set getModifiedFilepaths(String startRevision, String endRevision) throws IOException, InterruptedException; - void checkoutRevision(String revision) throws IOException, InterruptedException; - String getHeadSha() throws GitClientException, IOException, InterruptedException; - void ensureAllChangesAreCommitted() throws IOException, InterruptedException, GitClientException; -} - -class GitClientException extends Exception -{ - GitClientException(String message) - { - super(message); - } -} - -class GitClientImpl implements GitClient { - private Path workingDirectory; - - GitClientImpl(Path workingDirectory) { - this.workingDirectory = workingDirectory; - } - - @Override - public File getRepoRootDirectory() throws IOException, InterruptedException, GitClientException { - List gitOutput = performGitCommand("git", "rev-parse", "--show-toplevel"); - if (gitOutput.get(0) == null) { - throw new GitClientException("Unable to determine Git root directory, is this a Git repository"); - } - return new File(gitOutput.get(0)); - } - - @Override - public Set getModifiedFilepaths(String startRevision, String endRevision) throws IOException, InterruptedException { - List gitOutput = performGitCommand("git", "diff", "--name-only", startRevision, endRevision); - return gitOutput.stream().map( path -> new File(path).toPath()).collect(Collectors.toSet()); - } - - @Override - public void checkoutRevision(String revision) throws IOException, InterruptedException { - performGitCommand("git", "checkout", revision, "--quiet"); - } - - @Override - public String getHeadSha() throws GitClientException, IOException, InterruptedException { - List gitOutput = performGitCommand("git", "rev-parse", "HEAD"); - if (gitOutput.get(0) == null) { - throw new GitClientException("Unable to determine HEAD revision SHA"); - } - return gitOutput.get(0); - } - - @Override - public void ensureAllChangesAreCommitted() throws IOException, InterruptedException, GitClientException { - List gitOutput = performGitCommand("git", "status", "--porcelain"); - if (gitOutput.size() > 0) { - throw new GitClientException("There are working changes in the directory, please commit them and try again"); - } - } - - private List performGitCommand(String... command) throws IOException, InterruptedException { - ProcessBuilder pb = new ProcessBuilder( - command - ); - pb.directory(workingDirectory.toFile()); - Process process = pb.start(); - BufferedReader buffer = new BufferedReader( new InputStreamReader(process.getInputStream())); - return buffer.lines().collect(Collectors.toList()); - } -} diff --git a/src/main/java/com/bazel_diff/main.java b/src/main/java/com/bazel_diff/main.java index 6ed7eac..2582929 100644 --- a/src/main/java/com/bazel_diff/main.java +++ b/src/main/java/com/bazel_diff/main.java @@ -115,7 +115,6 @@ public Integer call() throws IOException { System.out.println("outputPath was not provided! Exiting"); return ExitCode.USAGE; } - GitClient gitClient = new GitClientImpl(workspacePath); BazelClient bazelClient = new BazelClientImpl( workspacePath, bazelPath, @@ -125,15 +124,6 @@ public Integer call() throws IOException { keepGoing ); TargetHashingClient hashingClient = new TargetHashingClientImpl(bazelClient, new FilesClientImp()); - try { - gitClient.ensureAllChangesAreCommitted(); - } catch (IOException | InterruptedException e) { - e.printStackTrace(); - return ExitCode.SOFTWARE; - } catch (GitClientException e) { - System.out.println(String.format("There are active changes in '%s', please commit these changes before running bazel-diffs", workspacePath)); - return ExitCode.USAGE; - } Gson gson = new Gson(); FileReader startingFileReader; FileReader finalFileReader;