Skip to content

Commit 44f940b

Browse files
committed
feat: add multi-failure test case & reduce redundancy in the ui
1 parent a712853 commit 44f940b

3 files changed

Lines changed: 35 additions & 12 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
7272
}
7373
}
7474

75-
pushContext.addStep(PushStep.builder()
76-
.stepName("checkAuthorEmails")
77-
.status(anyFailed ? StepStatus.FAIL : StepStatus.PASS)
78-
.blockedMessage(anyFailed ? "One or more author emails failed validation" : null)
79-
.logs(logs)
80-
.build());
75+
// Only add a summary step when passing — failures are already captured as per-issue
76+
// steps by ValidationContext and stored by validationResultHook, so a summary FAIL
77+
// step here would duplicate those entries in the UI.
78+
if (!anyFailed) {
79+
pushContext.addStep(PushStep.builder()
80+
.stepName("checkAuthorEmails")
81+
.status(StepStatus.PASS)
82+
.logs(logs)
83+
.build());
84+
}
8185
}
8286

8387
private List<Commit> getCommits(Repository repo, ReceiveCommand cmd) throws Exception {

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
7373
}
7474
}
7575

76-
pushContext.addStep(PushStep.builder()
77-
.stepName("checkCommitMessages")
78-
.status(anyFailed ? StepStatus.FAIL : StepStatus.PASS)
79-
.blockedMessage(anyFailed ? "One or more commit messages failed validation" : null)
80-
.logs(logs)
81-
.build());
76+
// Only add a summary step when passing — failures are already captured as per-issue
77+
// steps by ValidationContext and stored by validationResultHook, so a summary FAIL
78+
// step here would duplicate those entries in the UI.
79+
if (!anyFailed) {
80+
pushContext.addStep(PushStep.builder()
81+
.stepName("checkCommitMessages")
82+
.status(StepStatus.PASS)
83+
.logs(logs)
84+
.build());
85+
}
8286
}
8387

8488
private List<Commit> getCommits(Repository repo, ReceiveCommand cmd) throws Exception {

test-push-fail.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ test_token_in_message() {
111111
git commit -m "chore: rotate token=ghp_abc123def456 in CI config"
112112
}
113113

114+
# Both email AND message checks fail in the same push — useful for
115+
# verifying the UI displays multiple simultaneous validation failures.
116+
test_multi_failure() {
117+
# blocked local part (noreply) + non-allowed domain = email fails
118+
git config user.name "Noreply Bot"
119+
git config user.email "noreply@internal.corp.net"
120+
echo "multi failure test - $(date)" >> test-file.txt
121+
git add test-file.txt
122+
# WIP literal + embedded secret pattern = message fails twice
123+
git commit -m "WIP: temp debug, password=hunter2 hardcoded"
124+
}
125+
114126
# --- Run tests ---
115127

116128
echo "=========================================================="
@@ -130,6 +142,9 @@ run_test "FAIL: DO NOT MERGE message" fail test_do_not_merge_message
130142
run_test "FAIL: password in commit message" fail test_secret_in_message
131143
run_test "FAIL: token in commit message" fail test_token_in_message
132144

145+
# Multi-check failure
146+
run_test "FAIL: blocked email + WIP + secret in message (multi-check)" fail test_multi_failure
147+
133148
echo ""
134149
echo "=========================================================="
135150
echo " RESULTS: ${PASS} passed, ${FAIL} unexpected"

0 commit comments

Comments
 (0)