Skip to content

Commit 9749c6e

Browse files
coopernetesclaude
andcommitted
style: fix spotless formatting violations in new filter files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 41c20c1 commit 9749c6e

7 files changed

Lines changed: 41 additions & 37 deletions

File tree

jgit-proxy-core/src/main/java/org/finos/gitproxy/git/CheckEmptyBranchHook.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
5858
}
5959

6060
private List<Commit> getCommits(Repository repo, ReceiveCommand cmd) throws Exception {
61-
return CommitInspectionService.getCommitRange(repo, cmd.getOldId().name(), cmd.getNewId().name());
61+
return CommitInspectionService.getCommitRange(
62+
repo, cmd.getOldId().name(), cmd.getNewId().name());
6263
}
6364
}

jgit-proxy-core/src/main/java/org/finos/gitproxy/git/CheckHiddenCommitsHook.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.Collection;
88
import java.util.HashSet;
99
import java.util.Set;
10-
import java.util.stream.Collectors;
1110
import lombok.extern.slf4j.Slf4j;
1211
import org.eclipse.jgit.lib.ObjectId;
1312
import org.eclipse.jgit.lib.Ref;
@@ -60,7 +59,8 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
6059
+ " and pushed to the remote.\n"
6160
+ "Please get approval on the commits, push them and try again.";
6261

63-
rp.sendMessage(RED + "[git-proxy] " + NO_ENTRY.emoji() + " Push blocked — hidden commits detected" + RESET);
62+
rp.sendMessage(
63+
RED + "[git-proxy] " + NO_ENTRY.emoji() + " Push blocked — hidden commits detected" + RESET);
6464
rp.sendMessage(YELLOW + "[git-proxy] " + WARNING.emoji() + " " + msg + RESET);
6565

6666
for (ReceiveCommand cmd : commands) {
@@ -74,12 +74,14 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
7474
}
7575
}
7676

77-
private Set<String> collectIntroducedCommits(Repository repo, Collection<ReceiveCommand> commands) throws Exception {
77+
private Set<String> collectIntroducedCommits(Repository repo, Collection<ReceiveCommand> commands)
78+
throws Exception {
7879
Set<String> introduced = new HashSet<>();
7980
for (ReceiveCommand cmd : commands) {
8081
if (cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED) continue;
8182
if (cmd.getType() == ReceiveCommand.Type.DELETE) continue;
82-
CommitInspectionService.getCommitRange(repo, cmd.getOldId().name(), cmd.getNewId().name())
83+
CommitInspectionService.getCommitRange(
84+
repo, cmd.getOldId().name(), cmd.getNewId().name())
8385
.stream()
8486
.map(Commit::getSha)
8587
.forEach(introduced::add);

jgit-proxy-core/src/main/java/org/finos/gitproxy/servlet/filter/CheckEmptyBranchFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* state problem.
2424
* </ul>
2525
*
26-
* <p>This filter short-circuits immediately via {@link #rejectAndSendError} without recording to {@link
27-
* org.finos.gitproxy.servlet.filter.ValidationSummaryFilter}.
26+
* <p>This filter short-circuits immediately via {@link #rejectAndSendError} without recording to
27+
* {@link org.finos.gitproxy.servlet.filter.ValidationSummaryFilter}.
2828
*
2929
* <p>Runs at order 2050, before all other content validation filters.
3030
*/

jgit-proxy-core/src/main/java/org/finos/gitproxy/servlet/filter/CheckHiddenCommitsFilter.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.eclipse.jgit.revwalk.RevCommit;
1818
import org.eclipse.jgit.revwalk.RevWalk;
1919
import org.finos.gitproxy.git.Commit;
20-
import org.finos.gitproxy.git.CommitInspectionService;
2120
import org.finos.gitproxy.git.GitClient;
2221
import org.finos.gitproxy.git.GitRequestDetails;
2322
import org.finos.gitproxy.git.HttpOperation;
@@ -38,9 +37,9 @@
3837
* <li><b>hidden</b> = {@code allNew} ∖ {@code introduced}.
3938
* </ol>
4039
*
41-
* <p>This filter short-circuits immediately via {@link #rejectAndSendError} without recording to {@link
42-
* ValidationSummaryFilter}. Requires {@link EnrichPushCommitsFilter} to have run first (for both {@code pushedCommits}
43-
* and the unpacked local repository).
40+
* <p>This filter short-circuits immediately via {@link #rejectAndSendError} without recording to
41+
* {@link ValidationSummaryFilter}. Requires {@link EnrichPushCommitsFilter} to have run first (for both
42+
* {@code pushedCommits} and the unpacked local repository).
4443
*
4544
* <p>Runs at order 2060, before all other content validation filters.
4645
*/
@@ -73,9 +72,7 @@ public void doHttpFilter(HttpServletRequest request, HttpServletResponse respons
7372

7473
Set<String> introduced = requestDetails.getPushedCommits() == null
7574
? Set.of()
76-
: requestDetails.getPushedCommits().stream()
77-
.map(Commit::getSha)
78-
.collect(Collectors.toSet());
75+
: requestDetails.getPushedCommits().stream().map(Commit::getSha).collect(Collectors.toSet());
7976

8077
try {
8178
String remoteUrl = constructRemoteUrl(requestDetails);
@@ -100,7 +97,8 @@ public void doHttpFilter(HttpServletRequest request, HttpServletResponse respons
10097
+ " and pushed to the remote.\n"
10198
+ "Please get approval on the commits, push them and try again.";
10299

103-
rejectAndSendError(request, response, "Hidden commits detected", GitClient.format(title, message, RED, null));
100+
rejectAndSendError(
101+
request, response, "Hidden commits detected", GitClient.format(title, message, RED, null));
104102

105103
} catch (Exception e) {
106104
log.error("Failed to check hidden commits", e);

jgit-proxy-core/src/test/java/org/finos/gitproxy/servlet/filter/PushFinalizerFilterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ private GitRequestDetails pendingPushDetails() {
9090
GitRequestDetails details = new GitRequestDetails();
9191
details.setOperation(HttpOperation.PUSH);
9292
details.setCommitTo("abc123");
93-
details.setRepository(GitRequestDetails.Repository.builder().slug("owner/repo").build());
93+
details.setRepository(
94+
GitRequestDetails.Repository.builder().slug("owner/repo").build());
9495
return details;
9596
}
9697

jgit-proxy-server/src/test/java/org/finos/gitproxy/e2e/GitHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void commit(Path repoDir, String message) throws IOException, InterruptedExcepti
5555
}
5656

5757
/**
58-
* Creates a new local branch at the current HEAD and checks it out. No new commits are made, so the branch tip
59-
* is identical to the source branch — useful for testing empty-branch rejection.
58+
* Creates a new local branch at the current HEAD and checks it out. No new commits are made, so the branch tip is
59+
* identical to the source branch — useful for testing empty-branch rejection.
6060
*/
6161
void createAndCheckoutBranch(Path repoDir, String branchName) throws IOException, InterruptedException {
6262
git(repoDir, "checkout", "-b", branchName);

jgit-proxy-server/src/test/java/org/finos/gitproxy/e2e/ProxyModeE2ETest.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ private PushStore pushStore() {
6969
return proxy.getPushStore();
7070
}
7171

72-
/**
73-
* Clones, commits, and pushes. Returns the push result (exit code + output) so the caller can assert on it.
74-
*/
72+
/** Clones, commits, and pushes. Returns the push result (exit code + output) so the caller can assert on it. */
7573
private GitHelper.PushResult cloneCommitPush(String dirSuffix, String authorEmail, String commitMessage)
7674
throws Exception {
7775
GitHelper git = helper();
@@ -107,12 +105,15 @@ var record = pushStore().findById(pushId);
107105
assertEquals(PushStatus.BLOCKED, record.get().getStatus(), "push should be BLOCKED pending review");
108106

109107
// Approve the push
110-
pushStore().approve(pushId, Attestation.builder()
111-
.pushId(pushId)
112-
.type(Attestation.Type.APPROVAL)
113-
.reviewerUsername("e2e-test-reviewer")
114-
.reason("Approved by e2e test")
115-
.build());
108+
pushStore()
109+
.approve(
110+
pushId,
111+
Attestation.builder()
112+
.pushId(pushId)
113+
.type(Attestation.Type.APPROVAL)
114+
.reviewerUsername("e2e-test-reviewer")
115+
.reason("Approved by e2e test")
116+
.build());
116117

117118
// Re-push — should succeed now
118119
var rePush = git.pushWithResult(repo);
@@ -147,12 +148,15 @@ void multipleCleanCommits_blockedThenApproved() throws Exception {
147148
String pushId = firstPush.extractPushId();
148149

149150
// Approve
150-
pushStore().approve(pushId, Attestation.builder()
151-
.pushId(pushId)
152-
.type(Attestation.Type.APPROVAL)
153-
.reviewerUsername("e2e-test-reviewer")
154-
.reason("Approved by e2e test")
155-
.build());
151+
pushStore()
152+
.approve(
153+
pushId,
154+
Attestation.builder()
155+
.pushId(pushId)
156+
.type(Attestation.Type.APPROVAL)
157+
.reviewerUsername("e2e-test-reviewer")
158+
.reason("Approved by e2e test")
159+
.build());
156160

157161
// Re-push — should succeed
158162
var rePush = git.pushWithResult(repo);
@@ -180,8 +184,7 @@ void noReplyHyphenLocalPart_rejected() throws Exception {
180184
@Test
181185
@Order(12)
182186
void nonAllowedEmailDomain_rejected() throws Exception {
183-
var result = cloneCommitPush(
184-
"proxy-fail-domain", "developer@internal.corp.net", "feat: non-allowed domain");
187+
var result = cloneCommitPush("proxy-fail-domain", "developer@internal.corp.net", "feat: non-allowed domain");
185188
assertFalse(result.succeeded(), "push with disallowed email domain should be rejected");
186189
}
187190

@@ -196,8 +199,7 @@ void githubNoreplyEmail_rejected() throws Exception {
196199
@Test
197200
@Order(20)
198201
void wipCommitMessage_rejected() throws Exception {
199-
var result =
200-
cloneCommitPush("proxy-fail-wip", GiteaContainer.VALID_AUTHOR_EMAIL, "WIP: still working on this");
202+
var result = cloneCommitPush("proxy-fail-wip", GiteaContainer.VALID_AUTHOR_EMAIL, "WIP: still working on this");
201203
assertFalse(result.succeeded(), "push with WIP message should be rejected");
202204
}
203205

0 commit comments

Comments
 (0)