зеркало из https://github.com/Azure/ARO-RP.git
Add git hooks for branch name validation (#3479)
This commit is contained in:
Родитель
1495c32317
Коммит
2d6b88cb10
5
Makefile
5
Makefile
|
@ -113,6 +113,9 @@ generate-kiota:
|
|||
go run ./hack/validate-imports pkg/util/graph/graphsdk
|
||||
go run ./hack/licenses -dirs ./pkg/util/graph/graphsdk
|
||||
|
||||
init-contrib:
|
||||
cp -R hack/git/hooks/* .git/hooks/
|
||||
|
||||
image-aro-multistage:
|
||||
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-multistage -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
|
||||
|
||||
|
@ -270,4 +273,4 @@ vendor:
|
|||
install-go-tools:
|
||||
go install ${GOTESTSUM}
|
||||
|
||||
.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal clean client deploy dev-config.yaml discoverycache generate image-aro-multistage image-fluentbit image-proxy lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools
|
||||
.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal clean client deploy dev-config.yaml discoverycache generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools
|
|
@ -29,6 +29,13 @@ you to agree to a Contributor License Agreement (CLA) declaring that you have
|
|||
the right to, and actually do, grant us the rights to use your contribution. For
|
||||
details, visit https://cla.microsoft.com.
|
||||
|
||||
Before you start development, please set up your local git hooks to conform to our
|
||||
development standards:
|
||||
|
||||
```bash
|
||||
make init-contrib
|
||||
```
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether
|
||||
you need to provide a CLA and decorate the PR appropriately (e.g., label,
|
||||
comment). Simply follow the instructions provided by the bot. You will only need
|
||||
|
|
|
@ -138,3 +138,9 @@ Make sure that `PKG_CONFIG_PATH` contains the pkgconfig files of the above packa
|
|||
```bash
|
||||
cd ${GOPATH:-$HOME/go}/src/github.com/Azure/ARO-RP
|
||||
```
|
||||
|
||||
1. Add standard git hooks
|
||||
|
||||
```bash
|
||||
make init-contrib
|
||||
```
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
LC_ALL=C
|
||||
|
||||
git_username_lower="$(git config github.user | tr '[:upper:]' '[:lower:]')"
|
||||
if [[ -z "${git_username_lower}" ]]
|
||||
then
|
||||
echo "Please set github.user (git config github.user) locally or globally before issuing commits to this repo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# e.g. "USERNAME/ARO-1234", "USERNAME/hotfix-v20240321.00", or "USERNAME/gh-issue-123"
|
||||
valid_branch_regex="^${git_username_lower}\/(ARO-[0-9]{4}[a-z0-9._-]*|hotfix-[a-z0-9._-]+|gh-issue-[0-9]+[a-z0-9._-]*)$"
|
||||
|
||||
local_branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
if [[ ! $local_branch =~ $valid_branch_regex ]]
|
||||
then
|
||||
echo "There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. Please rename your branch (git branch --move) to a valid name and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
Загрузка…
Ссылка в новой задаче