From 60c91b8d32fc8687f6674ce8c21bfc060667edfe Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 14 May 2026 12:08:29 -0700 Subject: [PATCH 1/3] chore: add githooks to guard against unexpected commits --- .githooks/pre-commit | 13 +++++++++++++ .github/MAINTAINERS_GUIDE.md | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..dcdd290d --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -e + +# Guard against committing directly to main +branch="$(git rev-parse --abbrev-ref HEAD)" +if [ "$branch" = "main" ]; then + echo "error: commits directly to main are not allowed. Use a development branch." + exit 1 +fi + +# Run linter on staged changes +cd "$(git rev-parse --show-toplevel)" || exit 1 +go tool golangci-lint run diff --git a/.github/MAINTAINERS_GUIDE.md b/.github/MAINTAINERS_GUIDE.md index d2a28019..be775f1e 100644 --- a/.github/MAINTAINERS_GUIDE.md +++ b/.github/MAINTAINERS_GUIDE.md @@ -207,6 +207,7 @@ Certain things are common during development and require a few commands. **Task outline:** - [Cloning the project](#cloning-the-project) + - [Git hooks](#git-hooks) - [Initializing the project](#initializing-the-project) - [Testing](#testing) - [Module and unit tests](#module-and-unit-tests) @@ -233,6 +234,19 @@ git clone https://github.com/slackapi/slack-cli.git cd slack-cli/ ``` +#### Git hooks + +Opt-in Git hooks are available in the `.githooks/` directory. To enable them: + +```zsh +git config core.hooksPath .githooks +``` + +The pre-commit hook will: + +- Block commits directly to the `main` branch +- Run `go tool golangci-lint run` to lint before committing + ### Initializing the project When you first clone the project or after you major updates to the project, it's From 5b2c0caa79805559a021f8744cd45adb2156f001 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 14 May 2026 12:26:52 -0700 Subject: [PATCH 2/3] fix: add license header to pre-commit hook Co-Authored-By: Claude --- .githooks/pre-commit | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index dcdd290d..50a3e7d3 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,4 +1,18 @@ #!/usr/bin/env bash +# Copyright 2022-2026 Salesforce, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + set -e # Guard against committing directly to main From f06978feff8ce4fbc3474846f9da9038e0a0653e Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Mon, 18 May 2026 09:26:37 -0700 Subject: [PATCH 3/3] chore: add githooks to agent directives --- .claude/CLAUDE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index ba3e8417..cbc75c77 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -207,6 +207,7 @@ See [`.github/STYLE_GUIDE.md`](../.github/STYLE_GUIDE.md) for conventions on com - `go.mod` - Go module dependencies and minimum Go version (see `go.mod` for current version) - `.circleci/config.yml` - CircleCI workflows for CI/CD pipeline - `.github/workflows/` - GitHub Actions for automated testing and releases +- `.githooks/` - Opt-in Git hooks (enable with `git config core.hooksPath .githooks`) ## Commit Message Format