native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #114 from supabitapp/chore/install-git-hooks

Add install-git-hooks target

authored by

khoi and committed by
GitHub
d6df5db8 0d80c789

+56 -4
+27
.githooks/pre-commit
··· 1 + #!/bin/sh 2 + set -e 3 + 4 + files_file=$(mktemp -t supacode-pre-commit.XXXXXX) 5 + trap 'rm -f "$files_file"' EXIT 6 + 7 + git diff --cached --name-only -z --diff-filter=ACMR -- '*.swift' > "$files_file" 8 + if [ ! -s "$files_file" ]; then 9 + exit 0 10 + fi 11 + 12 + unstaged=0 13 + while IFS= read -r -d '' file; do 14 + if ! git diff --quiet -- "$file"; then 15 + echo "unstaged changes present in: $file" 16 + unstaged=1 17 + fi 18 + done < "$files_file" 19 + if [ "$unstaged" -ne 0 ]; then 20 + echo "stash or stage all Swift changes before committing" 21 + exit 1 22 + fi 23 + 24 + make format FILES_FILE="$files_file" 25 + make lint FILES_FILE="$files_file" 26 + 27 + xargs -0 git add -- < "$files_file"
+29 -4
Makefile
··· 15 15 GHOSTTY_BUILD_OUTPUTS := $(GHOSTTY_XCFRAMEWORK_PATH) $(GHOSTTY_RESOURCE_PATH) $(GHOSTTY_TERMINFO_PATH) 16 16 VERSION ?= 17 17 BUILD ?= 18 + FILES_FILE ?= 18 19 19 20 .DEFAULT_GOAL := help 20 - .PHONY: serve build-ghostty-xcframework build-app run-app install-dev-build sync-ghostty-resources lint test update-wt bump-version bump-and-release 21 + .PHONY: serve build-ghostty-xcframework build-app run-app install-dev-build sync-ghostty-resources lint test update-wt bump-version bump-and-release install-git-hooks 21 22 22 23 help: # Display this help. 23 24 @-+echo "Run make with one of the following targets:" ··· 64 65 echo "installed $$dst" 65 66 66 67 lint: # Run swiftlint 67 - mise exec -- swiftlint --quiet 68 + if [ -n "$(FILES_FILE)" ]; then \ 69 + if [ ! -s "$(FILES_FILE)" ]; then \ 70 + exit 0; \ 71 + fi; \ 72 + while IFS= read -r -d '' file; do \ 73 + mise exec -- swiftlint --quiet --path "$$file"; \ 74 + done < "$(FILES_FILE)"; \ 75 + else \ 76 + mise exec -- swiftlint --quiet; \ 77 + fi 68 78 69 79 test: build-ghostty-xcframework 70 80 xcodebuild test -project supacode.xcodeproj -scheme supacode -destination "platform=macOS" CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" -skipMacroValidation 2>&1 71 81 72 82 format: # Swift format 73 - swift-format -p --in-place --recursive --configuration ./.swift-format.json supacode supacodeTests 74 - mise exec -- swiftlint --fix --quiet 83 + if [ -n "$(FILES_FILE)" ]; then \ 84 + if [ ! -s "$(FILES_FILE)" ]; then \ 85 + exit 0; \ 86 + fi; \ 87 + xargs -0 swift-format -p --in-place --configuration ./.swift-format.json -- < "$(FILES_FILE)"; \ 88 + while IFS= read -r -d '' file; do \ 89 + mise exec -- swiftlint --fix --quiet --path "$$file"; \ 90 + done < "$(FILES_FILE)"; \ 91 + else \ 92 + swift-format -p --in-place --recursive --configuration ./.swift-format.json supacode supacodeTests; \ 93 + mise exec -- swiftlint --fix --quiet; \ 94 + fi 95 + 96 + install-git-hooks: # Install git hooks to format/lint staged files 97 + @mkdir -p "$(CURRENT_MAKEFILE_DIR)/.githooks" 98 + @git config core.hooksPath "$(CURRENT_MAKEFILE_DIR)/.githooks" 99 + @chmod +x "$(CURRENT_MAKEFILE_DIR)/.githooks/pre-commit" 75 100 76 101 update-wt: # Download git-wt binary to Resources 77 102 @mkdir -p "$(CURRENT_MAKEFILE_DIR)/Resources/git-wt"