Skip to content

Commit 21eb237

Browse files
committed
Adjust cases of RR and push events
1 parent 0ee9f19 commit 21eb237

File tree

10 files changed

+165
-156
lines changed

10 files changed

+165
-156
lines changed

git/pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,17 @@
1616
</properties>
1717

1818
<dependencies>
19+
<dependency>
20+
<groupId>io.github.solven-eu.cleanthat</groupId>
21+
<artifactId>code-providers</artifactId>
22+
<version>${project.version}</version>
23+
</dependency>
24+
25+
26+
<dependency>
27+
<!-- Used to clone a repo -->
28+
<groupId>org.eclipse.jgit</groupId>
29+
<artifactId>org.eclipse.jgit</artifactId>
30+
</dependency>
1931
</dependencies>
2032
</project>

github/src/main/java/eu/solven/cleanthat/jgit/JGitCodeProvider.java renamed to git/src/main/java/eu/solven/cleanthat/jgit/JGitCodeProvider.java

+3-28
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@
3030
import org.eclipse.jgit.revwalk.RevWalk;
3131
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
3232
import org.eclipse.jgit.treewalk.TreeWalk;
33-
import org.kohsuke.github.GHRef;
34-
import org.kohsuke.github.GHRepository;
3533
import org.slf4j.Logger;
3634
import org.slf4j.LoggerFactory;
3735

3836
import com.google.common.base.Strings;
3937

40-
import eu.solven.cleanthat.code_provider.github.code_provider.AGithubCodeProvider;
4138
import eu.solven.cleanthat.codeprovider.DummyCodeProviderFile;
4239
import eu.solven.cleanthat.codeprovider.ICodeProvider;
4340
import eu.solven.cleanthat.codeprovider.ICodeProviderFile;
@@ -49,7 +46,7 @@
4946
* @author Benoit Lacelle
5047
*/
5148
@SuppressWarnings("PMD.GodClass")
52-
public class JGitCodeProvider extends AGithubCodeProvider implements ICodeProviderWriter {
49+
public class JGitCodeProvider implements ICodeProviderWriter {
5350

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

@@ -154,24 +151,6 @@ private static TreeWalk buildTreeWalk(Repository repository, RevTree tree, final
154151
return treeWalk;
155152
}
156153

157-
// @Override
158-
// public boolean deprecatedFileIsRemoved(Object file) {
159-
// String relativePath = (String) file;
160-
// Path path = workingDir.resolve(relativePath);
161-
//
162-
// if (!path.startsWith(workingDir)) {
163-
// // https://stackoverflow.com/questions/53157337/validate-to-prevent-a-path-string-to-go-up-to-parent-folder
164-
// throw new IllegalArgumentException("Can not move out of the parent folder");
165-
// }
166-
//
167-
// return !path.toFile().exists();
168-
// }
169-
170-
public static String loadContent(GHRepository repository, GHRef ref, String filename) throws IOException {
171-
String sha1 = ref.getObject().getSha();
172-
return loadContent(repository, filename, sha1);
173-
}
174-
175154
@Override
176155
public String getHtmlUrl() {
177156
try {
@@ -189,13 +168,9 @@ public String getTitle() {
189168
@Override
190169
public void persistChanges(Map<String, String> pathToMutatedContent,
191170
List<String> prComments,
192-
Collection<String> prLabels
193-
// , Optional<String> targetBranch
194-
) {
195-
// targetBranch
196-
171+
Collection<String> prLabels) {
197172
pathToMutatedContent.forEach((k, v) -> {
198-
Path resolvedPath = workingDir.resolve((String) k);
173+
Path resolvedPath = workingDir.resolve(k);
199174

200175
try {
201176
Files.writeString(resolvedPath, v, StandardOpenOption.TRUNCATE_EXISTING);

github/pom.xml

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
@@ -61,24 +62,18 @@
6162
</dependency>
6263

6364
<dependency>
64-
<!-- Used to clone a repo -->
65-
<groupId>org.eclipse.jgit</groupId>
66-
<artifactId>org.eclipse.jgit</artifactId>
65+
<groupId>io.github.solven-eu.cleanthat</groupId>
66+
<artifactId>git</artifactId>
67+
<version>${project.version}</version>
6768
</dependency>
6869

6970
<dependency>
7071
<!-- Encrypt login token, and sensible data in DB -->
72+
<!-- Enables loading a PEM file -->
7173
<groupId>com.nimbusds</groupId>
7274
<artifactId>nimbus-jose-jwt</artifactId>
7375
</dependency>
7476

75-
<!-- <dependency> -->
76-
<!-- Enables loading a PEM file -->
77-
<!-- <groupId>com.nimbusds</groupId> -->
78-
<!-- <artifactId>nimbus-jose-jwt</artifactId> -->
79-
<!-- <version>8.17</version> -->
80-
<!-- <scope>test</scope> -->
81-
<!-- </dependency> -->
8277
<dependency>
8378
<!-- Enables loading a PEM file -->
8479
<groupId>org.bouncycastle</groupId>
@@ -87,13 +82,6 @@
8782
<scope>test</scope>
8883
</dependency>
8984

90-
91-
<dependency>
92-
<groupId>ch.qos.logback</groupId>
93-
<artifactId>logback-classic</artifactId>
94-
<scope>test</scope>
95-
</dependency>
96-
9785
<dependency>
9886
<groupId>org.springframework.boot</groupId>
9987
<artifactId>spring-boot-starter-test</artifactId>
@@ -106,6 +94,5 @@
10694
<version>${project.version}</version>
10795
<scope>test</scope>
10896
</dependency>
109-
11097
</dependencies>
11198
</project>

0 commit comments

Comments
 (0)