Skip to content

Commit a4142e1

Browse files
coopernetesclaude
andcommitted
chore: apply spotless reformatting with palantir-java-format 2.90.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent aa406df commit a4142e1

14 files changed

Lines changed: 114 additions & 122 deletions

File tree

jgit-proxy-core/src/main/java/org/finos/gitproxy/db/PushRecordMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public static PushRecord fromRequestDetails(GitRequestDetails details) {
4545
}
4646
// Construct the upstream URL from provider URI + repo slug
4747
String providerUri = details.getProvider().getUri().toString();
48-
String slug = details.getRepository() != null ? details.getRepository().getSlug() : null;
48+
String slug =
49+
details.getRepository() != null ? details.getRepository().getSlug() : null;
4950
if (slug != null) {
5051
String upstreamUrl = providerUri.endsWith("/") ? providerUri + slug : providerUri + "/" + slug;
5152
builder.upstreamUrl(upstreamUrl);

jgit-proxy-core/src/main/java/org/finos/gitproxy/db/jdbc/JdbcPushStore.java

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public void initialize() {
5353

5454
@Override
5555
public void save(PushRecord record) {
56-
String insertSql =
57-
"""
56+
String insertSql = """
5857
INSERT INTO push_records (id, timestamp, url, upstream_url, project, repo_name, branch,
5958
commit_from, commit_to, message, author, author_email, committer, committer_email,
6059
push_user, user_email, method, status, error_message, blocked_message, auto_approved, auto_rejected)
@@ -202,8 +201,7 @@ private PushRecord updateStatus(String id, PushStatus status, Attestation attest
202201
try (Connection conn = dataSource.getConnection()) {
203202
conn.setAutoCommit(false);
204203
try {
205-
try (PreparedStatement ps =
206-
conn.prepareStatement("UPDATE push_records SET status = ? WHERE id = ?")) {
204+
try (PreparedStatement ps = conn.prepareStatement("UPDATE push_records SET status = ? WHERE id = ?")) {
207205
ps.setString(1, status.name());
208206
ps.setString(2, id);
209207
int updated = ps.executeUpdate();
@@ -269,36 +267,35 @@ private PushRecord mapRecord(ResultSet rs) throws SQLException {
269267
}
270268

271269
private void bindPushRecord(PreparedStatement ps, PushRecord r) throws SQLException {
272-
ps.setString(1, r.getId()); // id
270+
ps.setString(1, r.getId()); // id
273271
ps.setTimestamp(2, Timestamp.from(r.getTimestamp())); // timestamp
274-
ps.setString(3, r.getUrl()); // url
275-
ps.setString(4, r.getUpstreamUrl()); // upstream_url
276-
ps.setString(5, r.getProject()); // project
277-
ps.setString(6, r.getRepoName()); // repo_name
278-
ps.setString(7, r.getBranch()); // branch
279-
ps.setString(8, r.getCommitFrom()); // commit_from
280-
ps.setString(9, r.getCommitTo()); // commit_to
281-
ps.setString(10, r.getMessage()); // message
282-
ps.setString(11, r.getAuthor()); // author
283-
ps.setString(12, r.getAuthorEmail()); // author_email
284-
ps.setString(13, r.getCommitter()); // committer
285-
ps.setString(14, r.getCommitterEmail()); // committer_email
286-
ps.setString(15, r.getUser()); // push_user
287-
ps.setString(16, r.getUserEmail()); // user_email
288-
ps.setString(17, r.getMethod()); // method
289-
ps.setString(18, r.getStatus().name()); // status
290-
ps.setString(19, r.getErrorMessage()); // error_message
291-
ps.setString(20, r.getBlockedMessage()); // blocked_message
292-
ps.setBoolean(21, r.isAutoApproved()); // auto_approved
293-
ps.setBoolean(22, r.isAutoRejected()); // auto_rejected
272+
ps.setString(3, r.getUrl()); // url
273+
ps.setString(4, r.getUpstreamUrl()); // upstream_url
274+
ps.setString(5, r.getProject()); // project
275+
ps.setString(6, r.getRepoName()); // repo_name
276+
ps.setString(7, r.getBranch()); // branch
277+
ps.setString(8, r.getCommitFrom()); // commit_from
278+
ps.setString(9, r.getCommitTo()); // commit_to
279+
ps.setString(10, r.getMessage()); // message
280+
ps.setString(11, r.getAuthor()); // author
281+
ps.setString(12, r.getAuthorEmail()); // author_email
282+
ps.setString(13, r.getCommitter()); // committer
283+
ps.setString(14, r.getCommitterEmail()); // committer_email
284+
ps.setString(15, r.getUser()); // push_user
285+
ps.setString(16, r.getUserEmail()); // user_email
286+
ps.setString(17, r.getMethod()); // method
287+
ps.setString(18, r.getStatus().name()); // status
288+
ps.setString(19, r.getErrorMessage()); // error_message
289+
ps.setString(20, r.getBlockedMessage()); // blocked_message
290+
ps.setBoolean(21, r.isAutoApproved()); // auto_approved
291+
ps.setBoolean(22, r.isAutoRejected()); // auto_rejected
294292
}
295293

296294
// --- Steps ---
297295

298296
private void saveSteps(Connection conn, String pushId, List<PushStep> steps) throws SQLException {
299297
if (steps == null || steps.isEmpty()) return;
300-
String sql =
301-
"""
298+
String sql = """
302299
INSERT INTO push_steps (id, push_id, step_name, step_order, status, content,
303300
error_message, blocked_message, logs, timestamp)
304301
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
@@ -350,8 +347,7 @@ private List<PushStep> loadSteps(Connection conn, String pushId) throws SQLExcep
350347

351348
private void saveCommits(Connection conn, String pushId, List<PushCommit> commits) throws SQLException {
352349
if (commits == null || commits.isEmpty()) return;
353-
String sql =
354-
"""
350+
String sql = """
355351
INSERT INTO push_commits (push_id, sha, parent_sha, author_name, author_email,
356352
committer_name, committer_email, message, commit_date, signature)
357353
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
@@ -401,8 +397,7 @@ private List<PushCommit> loadCommits(Connection conn, String pushId) throws SQLE
401397
// --- Attestation ---
402398

403399
private void saveAttestation(Connection conn, String pushId, Attestation att) throws SQLException {
404-
String sql =
405-
"""
400+
String sql = """
406401
INSERT INTO push_attestations (push_id, type, reviewer_username, reviewer_email,
407402
reason, automated, timestamp)
408403
VALUES (?, ?, ?, ?, ?, ?, ?)
@@ -466,5 +461,4 @@ private String loadSchema() {
466461
throw new RuntimeException("Failed to load schema", e);
467462
}
468463
}
469-
470464
}

jgit-proxy-core/src/main/java/org/finos/gitproxy/db/model/PushRecord.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public class PushRecord {
6161
/** Authenticated user performing the push. */
6262
private String user;
6363

64-
/**
65-
* Authenticated user's email. Populated when user management is available; null until then.
66-
*/
64+
/** Authenticated user's email. Populated when user management is available; null until then. */
6765
private String userEmail;
6866

6967
/** HTTP method used. */

jgit-proxy-core/src/main/java/org/finos/gitproxy/db/model/PushStep.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
import lombok.Builder;
88
import lombok.Data;
99

10-
/**
11-
* A single validation/processing step within a push. Captures what happened during each hook or filter execution.
12-
*/
10+
/** A single validation/processing step within a push. Captures what happened during each hook or filter execution. */
1311
@Data
1412
@Builder
1513
public class PushStep {

jgit-proxy-core/src/main/java/org/finos/gitproxy/db/mongo/MongoPushStore.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.mongodb.client.model.Filters;
77
import com.mongodb.client.model.Indexes;
88
import com.mongodb.client.model.Sorts;
9-
import java.time.Instant;
109
import java.util.ArrayList;
1110
import java.util.Date;
1211
import java.util.List;
@@ -156,12 +155,16 @@ private static Document toDocument(PushRecord r) {
156155
.append("autoRejected", r.isAutoRejected());
157156

158157
if (r.getSteps() != null && !r.getSteps().isEmpty()) {
159-
doc.append("steps", r.getSteps().stream().map(MongoPushStore::stepToDocument).toList());
158+
doc.append(
159+
"steps",
160+
r.getSteps().stream().map(MongoPushStore::stepToDocument).toList());
160161
}
161162
if (r.getCommits() != null && !r.getCommits().isEmpty()) {
162-
doc.append("commits", r.getCommits().stream()
163-
.map(MongoPushStore::commitToDocument)
164-
.toList());
163+
doc.append(
164+
"commits",
165+
r.getCommits().stream()
166+
.map(MongoPushStore::commitToDocument)
167+
.toList());
165168
}
166169
if (r.getAttestation() != null) {
167170
doc.append("attestation", attestationToDocument(r.getAttestation()));
@@ -197,12 +200,16 @@ private static PushRecord fromDocument(Document doc) {
197200

198201
List<Document> stepDocs = doc.getList("steps", Document.class);
199202
if (stepDocs != null) {
200-
builder.steps(stepDocs.stream().map(MongoPushStore::stepFromDocument).collect(ArrayList::new, List::add, List::addAll));
203+
builder.steps(stepDocs.stream()
204+
.map(MongoPushStore::stepFromDocument)
205+
.collect(ArrayList::new, List::add, List::addAll));
201206
}
202207

203208
List<Document> commitDocs = doc.getList("commits", Document.class);
204209
if (commitDocs != null) {
205-
builder.commits(commitDocs.stream().map(MongoPushStore::commitFromDocument).collect(ArrayList::new, List::add, List::addAll));
210+
builder.commits(commitDocs.stream()
211+
.map(MongoPushStore::commitFromDocument)
212+
.collect(ArrayList::new, List::add, List::addAll));
206213
}
207214

208215
Document attDoc = doc.get("attestation", Document.class);

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,11 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
6868
}
6969

7070
private void generatePushDiff(
71-
ReceivePack rp,
72-
Repository repo,
73-
String refName,
74-
String commitFrom,
75-
String commitTo,
76-
boolean isNewBranch) {
71+
ReceivePack rp, Repository repo, String refName, String commitFrom, String commitTo, boolean isNewBranch) {
7772
try {
7873
String baseLabel = isNewBranch ? "(empty tree)" : commitFrom.substring(0, 7);
79-
rp.sendMessage(CYAN + "[git-proxy] " + LINK.emoji() + " Generating push diff "
80-
+ baseLabel + ".." + commitTo.substring(0, 7) + RESET);
74+
rp.sendMessage(CYAN + "[git-proxy] " + LINK.emoji() + " Generating push diff " + baseLabel + ".."
75+
+ commitTo.substring(0, 7) + RESET);
8176

8277
String diff = CommitInspectionService.getFormattedDiff(repo, commitFrom, commitTo);
8378
int lines = diff.isEmpty() ? 0 : (int) diff.lines().count();
@@ -97,17 +92,16 @@ private void generatePushDiff(
9792
pushContext.addStep(step);
9893
} catch (IOException e) {
9994
log.error("Failed to generate push diff for {}", refName, e);
100-
rp.sendMessage(YELLOW + "[git-proxy] " + WARNING.emoji()
101-
+ " Could not generate push diff: " + e.getMessage() + RESET);
95+
rp.sendMessage(YELLOW + "[git-proxy] " + WARNING.emoji() + " Could not generate push diff: "
96+
+ e.getMessage() + RESET);
10297
}
10398
}
10499

105100
/**
106-
* Generate a diff of the pushed commit(s) relative to the repository's default branch. This helps reviewers see
107-
* the full scope of changes even when the push is part of a larger feature branch.
101+
* Generate a diff of the pushed commit(s) relative to the repository's default branch. This helps reviewers see the
102+
* full scope of changes even when the push is part of a larger feature branch.
108103
*/
109-
private void generateDefaultBranchDiff(
110-
ReceivePack rp, Repository repo, String pushRef, String commitTo) {
104+
private void generateDefaultBranchDiff(ReceivePack rp, Repository repo, String pushRef, String commitTo) {
111105
try {
112106
String defaultBranch = resolveDefaultBranch(repo);
113107
if (defaultBranch == null) {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ private void inspectCommits(ReceivePack rp, Repository repo, ReceiveCommand cmd,
8181
// For new branches (old is zero ID), we can't do a range — just inspect the tip
8282
if (ObjectId.zeroId().equals(cmd.getOldId())) {
8383
Commit tipCommit = CommitInspectionService.getCommitDetails(repo, toCommit);
84-
String tipLine = "New branch - tip commit by " + tipCommit.getAuthor().getName()
85-
+ " <" + tipCommit.getAuthor().getEmail() + ">";
84+
String tipLine =
85+
"New branch - tip commit by " + tipCommit.getAuthor().getName() + " <"
86+
+ tipCommit.getAuthor().getEmail() + ">";
8687
rp.sendMessage(CYAN + "[git-proxy] " + tipLine + RESET);
8788
logs.add(tipLine);
8889
return;
@@ -94,8 +95,8 @@ private void inspectCommits(ReceivePack rp, Repository repo, ReceiveCommand cmd,
9495
for (Commit commit : commits) {
9596
String shortSha = commit.getSha().substring(0, 7);
9697
String firstLine = commit.getMessage().lines().findFirst().orElse("(empty)");
97-
String line = shortSha + " " + commit.getAuthor().getName()
98-
+ " <" + commit.getAuthor().getEmail() + "> " + firstLine;
98+
String line = shortSha + " " + commit.getAuthor().getName() + " <"
99+
+ commit.getAuthor().getEmail() + "> " + firstLine;
99100
rp.sendMessage(MAGENTA + "[git-proxy] " + line + RESET);
100101
logs.add(line);
101102
}

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

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ public void setPushContext(PushContext pushContext) {
4747
this.pushContext = pushContext;
4848
}
4949

50-
/**
51-
* Returns a {@link PreReceiveHook} that creates the initial push record. Should be the first hook in the chain.
52-
*/
50+
/** Returns a {@link PreReceiveHook} that creates the initial push record. Should be the first hook in the chain. */
5351
public PreReceiveHook preReceiveHook() {
5452
return (ReceivePack rp, Collection<ReceiveCommand> commands) -> {
5553
String pushId = UUID.randomUUID().toString();
@@ -70,8 +68,8 @@ public PreReceiveHook preReceiveHook() {
7068
* Returns a {@link PreReceiveHook} that captures the validation results after all validation hooks have run. Should
7169
* be placed after all validation hooks but before the forwarding post-receive hook.
7270
*
73-
* <p>Creates a new event-log record for the validation outcome, linked to the original push via the same
74-
* upstream URL and commit range.
71+
* <p>Creates a new event-log record for the validation outcome, linked to the original push via the same upstream
72+
* URL and commit range.
7573
*/
7674
public PreReceiveHook validationResultHook(ValidationContext validationContext) {
7775
return (ReceivePack rp, Collection<ReceiveCommand> commands) -> {
@@ -100,8 +98,7 @@ public PreReceiveHook validationResultHook(ValidationContext validationContext)
10098
.build());
10199
}
102100
record.setStatus(PushStatus.BLOCKED);
103-
record.setBlockedMessage(
104-
validationContext.getIssues().size() + " validation issue(s) found");
101+
record.setBlockedMessage(validationContext.getIssues().size() + " validation issue(s) found");
105102
} else {
106103
record.setStatus(PushStatus.APPROVED);
107104
}
@@ -117,21 +114,19 @@ public PreReceiveHook validationResultHook(ValidationContext validationContext)
117114
record.setSteps(steps);
118115

119116
// Check if any commands were rejected by earlier hooks
120-
boolean anyRejected = commands.stream()
121-
.anyMatch(cmd -> cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED);
117+
boolean anyRejected =
118+
commands.stream().anyMatch(cmd -> cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED);
122119
if (anyRejected) {
123120
record.setStatus(PushStatus.BLOCKED);
124121
commands.stream()
125122
.filter(cmd -> cmd.getResult() != ReceiveCommand.Result.NOT_ATTEMPTED
126123
&& cmd.getResult() != ReceiveCommand.Result.OK)
127124
.findFirst()
128-
.ifPresent(cmd -> record.setBlockedMessage(
129-
cmd.getResult() + ": " + cmd.getMessage()));
125+
.ifPresent(cmd -> record.setBlockedMessage(cmd.getResult() + ": " + cmd.getMessage()));
130126
}
131127

132128
pushStore.save(record);
133-
log.debug(
134-
"Saved validation result record: id={}, status={}", record.getId(), record.getStatus());
129+
log.debug("Saved validation result record: id={}, status={}", record.getId(), record.getStatus());
135130
});
136131
} catch (Exception e) {
137132
log.error("Failed to save validation result record", e);
@@ -152,8 +147,7 @@ public PostReceiveHook postReceiveHook() {
152147

153148
try {
154149
pushStore.findById(pushId).ifPresent(initial -> {
155-
boolean allOk = commands.stream()
156-
.allMatch(cmd -> cmd.getResult() == ReceiveCommand.Result.OK);
150+
boolean allOk = commands.stream().allMatch(cmd -> cmd.getResult() == ReceiveCommand.Result.OK);
157151
boolean anyValidationRejected = commands.stream()
158152
.anyMatch(cmd -> cmd.getResult() == ReceiveCommand.Result.REJECTED_OTHER_REASON);
159153
boolean anyTransportFailed = commands.stream()
@@ -190,9 +184,8 @@ public PostReceiveHook postReceiveHook() {
190184
}
191185

192186
/**
193-
* Create a new record that copies the base fields (repo, branch, commits, author) from an existing record but
194-
* with a fresh ID and timestamp. Used for event-log style persistence where each state transition is a separate
195-
* row.
187+
* Create a new record that copies the base fields (repo, branch, commits, author) from an existing record but with
188+
* a fresh ID and timestamp. Used for event-log style persistence where each state transition is a separate row.
196189
*/
197190
private PushRecord copyBase(PushRecord source) {
198191
return PushRecord.builder()
@@ -276,8 +269,8 @@ private PushRecord buildInitialRecord(String pushId, ReceivePack rp, Collection<
276269
builder.message(tip.getMessage().lines().findFirst().orElse(null));
277270
}
278271
} else {
279-
List<Commit> range =
280-
CommitInspectionService.getCommitRange(repo, cmd.getOldId().name(), toCommit);
272+
List<Commit> range = CommitInspectionService.getCommitRange(
273+
repo, cmd.getOldId().name(), toCommit);
281274
for (Commit c : range) {
282275
commits.add(PushRecordMapper.mapCommit(pushId, c));
283276
}
@@ -293,7 +286,8 @@ private PushRecord buildInitialRecord(String pushId, ReceivePack rp, Collection<
293286
builder.committerEmail(head.getCommitter().getEmail());
294287
}
295288
if (head.getMessage() != null) {
296-
builder.message(head.getMessage().lines().findFirst().orElse(null));
289+
builder.message(
290+
head.getMessage().lines().findFirst().orElse(null));
297291
}
298292
}
299293
}

0 commit comments

Comments
 (0)