Skip to content

Commit

Permalink
Adjust cases of RR and push events
Browse files Browse the repository at this point in the history
  • Loading branch information
blacelle committed Aug 18, 2021
1 parent 0ee9f19 commit 21eb237
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 156 deletions.
12 changes: 12 additions & 0 deletions git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@
</properties>

<dependencies>
<dependency>
<groupId>io.github.solven-eu.cleanthat</groupId>
<artifactId>code-providers</artifactId>
<version>${project.version}</version>
</dependency>


<dependency>
<!-- Used to clone a repo -->
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.kohsuke.github.GHRef;
import org.kohsuke.github.GHRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Strings;

import eu.solven.cleanthat.code_provider.github.code_provider.AGithubCodeProvider;
import eu.solven.cleanthat.codeprovider.DummyCodeProviderFile;
import eu.solven.cleanthat.codeprovider.ICodeProvider;
import eu.solven.cleanthat.codeprovider.ICodeProviderFile;
Expand All @@ -49,7 +46,7 @@
* @author Benoit Lacelle
*/
@SuppressWarnings("PMD.GodClass")
public class JGitCodeProvider extends AGithubCodeProvider implements ICodeProviderWriter {
public class JGitCodeProvider implements ICodeProviderWriter {

private static final Logger LOGGER = LoggerFactory.getLogger(JGitCodeProvider.class);

Expand Down Expand Up @@ -154,24 +151,6 @@ private static TreeWalk buildTreeWalk(Repository repository, RevTree tree, final
return treeWalk;
}

// @Override
// public boolean deprecatedFileIsRemoved(Object file) {
// String relativePath = (String) file;
// Path path = workingDir.resolve(relativePath);
//
// if (!path.startsWith(workingDir)) {
// // https://stackoverflow.com/questions/53157337/validate-to-prevent-a-path-string-to-go-up-to-parent-folder
// throw new IllegalArgumentException("Can not move out of the parent folder");
// }
//
// return !path.toFile().exists();
// }

public static String loadContent(GHRepository repository, GHRef ref, String filename) throws IOException {
String sha1 = ref.getObject().getSha();
return loadContent(repository, filename, sha1);
}

@Override
public String getHtmlUrl() {
try {
Expand All @@ -189,13 +168,9 @@ public String getTitle() {
@Override
public void persistChanges(Map<String, String> pathToMutatedContent,
List<String> prComments,
Collection<String> prLabels
// , Optional<String> targetBranch
) {
// targetBranch

Collection<String> prLabels) {
pathToMutatedContent.forEach((k, v) -> {
Path resolvedPath = workingDir.resolve((String) k);
Path resolvedPath = workingDir.resolve(k);

try {
Files.writeString(resolvedPath, v, StandardOpenOption.TRUNCATE_EXISTING);
Expand Down
25 changes: 6 additions & 19 deletions github/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -61,24 +62,18 @@
</dependency>

<dependency>
<!-- Used to clone a repo -->
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<groupId>io.github.solven-eu.cleanthat</groupId>
<artifactId>git</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<!-- Encrypt login token, and sensible data in DB -->
<!-- Enables loading a PEM file -->
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>

<!-- <dependency> -->
<!-- Enables loading a PEM file -->
<!-- <groupId>com.nimbusds</groupId> -->
<!-- <artifactId>nimbus-jose-jwt</artifactId> -->
<!-- <version>8.17</version> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
<dependency>
<!-- Enables loading a PEM file -->
<groupId>org.bouncycastle</groupId>
Expand All @@ -87,13 +82,6 @@
<scope>test</scope>
</dependency>


<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -106,6 +94,5 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Loading

0 comments on commit 21eb237

Please sign in to comment.