Skip to content

Commit ccad8f8

Browse files
authored
Merge pull request #49 from github/edburns/re-enable-pre-commit-hooks
Edburns/re enable pre commit hooks
2 parents 828d300 + e665e21 commit ccad8f8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.github/copilot-instructions.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ When porting from .NET:
104104
- 4-space indentation (enforced by Spotless with Eclipse formatter)
105105
- Fluent setter pattern for configuration classes (e.g., `new SessionConfig().setModel("gpt-5").setTools(tools)`)
106106
- Public APIs require Javadoc (enforced by Checkstyle, except `json` and `events` packages)
107-
- Pre-commit hook runs `mvn spotless:check` - enable with: `git config core.hooksPath .githooks`
107+
- Pre-commit hook runs `mvn spotless:check` - Must be manually enabled with: `git config core.hooksPath .githooks`, except in the Copilot coding agent environment. This hook is explicitly enabled in the Copilot coding agent environment. See [copilot-setup-steps.yml](workflows/copilot-setup-steps.yml).
108108

109109
### Handler Pattern
110110

@@ -244,6 +244,18 @@ This SDK is designed to be **lightweight with minimal dependencies**:
244244
5. Check for security vulnerabilities
245245
6. Get team approval for non-trivial additions
246246

247+
## Pre-commit Hooks and Formatting (Coding Agent)
248+
249+
The repository has a pre-commit hook (`.githooks/pre-commit`) that is **automatically enabled** in the Copilot coding agent environment via `copilot-setup-steps.yml`. The hook runs `mvn spotless:check` on any commit that includes changes under `src/`.
250+
251+
**If a commit fails due to the pre-commit hook:**
252+
253+
1. Run `mvn spotless:apply` to auto-fix formatting issues.
254+
2. Re-stage the changed files with `git add -u`.
255+
3. Retry the commit.
256+
257+
**Best practice:** Always run `mvn spotless:apply` before committing Java source changes to avoid hook failures in the first place. If you forget and the hook rejects the commit, follow the three steps above and continue.
258+
247259
## Commit and PR Guidelines
248260

249261
### Commit Messages

.github/workflows/copilot-setup-steps.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
distribution: 'temurin'
4242
cache: 'maven'
4343

44+
# Enable repository pre-commit hooks (including Spotless checks for relevant source changes)
45+
- name: Enable pre-commit hooks
46+
run: git config core.hooksPath .githooks
47+
4448
# Verify installations
4549
- name: Verify tool installations
4650
run: |
@@ -50,4 +54,6 @@ jobs:
5054
java -version
5155
gh --version
5256
gh aw version
57+
echo "--- Git hooks path ---"
58+
git config core.hooksPath
5359
echo "✅ All tools installed successfully"

0 commit comments

Comments
 (0)