generated from GSA/grace-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from GSA/add-hooks
add git hooks
- Loading branch information
Showing
6 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
# GITLEAKS_PRECOMMIT_HOOK BEGIN | ||
precommit_latest_url=$(curl --silent --location --head --output /dev/null --write-out '%{url_effective}' -- https://github.com/GSA/odp-code-repository-commit-rules/releases/latest) | ||
precommit_version=${precommit_latest_url##*/} | ||
precommit_url="https://raw.githubusercontent.com/GSA/odp-code-repository-commit-rules/${precommit_version}/gitleaks/precommit.sh" | ||
precommit_path="$(git rev-parse --show-toplevel)/.git/hooks/precommit.sh" | ||
|
||
curl --silent -o "${precommit_path}" "${precommit_url}" | ||
os=$(uname -s | cut -d'_' -f 1) | ||
if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then | ||
chmod +x "${precommit_path}" | ||
fi | ||
|
||
"${precommit_path}" "${precommit_version}" | ||
# GITLEAKS_PRECOMMIT_HOOK END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ else | |
ghr -u $(CIRCLE_PROJECT_USERNAME) -r $(CIRCLE_PROJECT_REPONAME) -c $(CIRCLE_SHA1) -delete $(CIRCLE_TAG) $(RELEASEDIR) | ||
endif | ||
|
||
clean: | ||
clean: precommit | ||
rm -rf $(RELEASEDIR) | ||
|
||
test: lint | ||
|
@@ -47,7 +47,7 @@ ifeq (,$(wildcard go.mod)) | |
go mod init | ||
endif | ||
|
||
dependencies: $(GOLANGCILINT) $(GOSEC) $(GHR) | ||
dependencies: precommit $(GOLANGCILINT) $(GOSEC) $(GHR) | ||
|
||
$(GOLANGCILINT): | ||
go get -u github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
@@ -57,3 +57,8 @@ $(GOSEC): | |
|
||
$(GHR): | ||
go get -u github.com/tcnksm/ghr | ||
|
||
precommit: | ||
ifneq ($(strip $(hooksPath)),.github/hooks) | ||
@git config --add core.hooksPath .github/hooks | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters