Merge pull request #1405 from bitnami/githooks

Add git hooks
This commit is contained in:
Carlos Rodríguez Hernández
2019-09-10 11:50:52 +02:00
committed by GitHub
3 changed files with 50 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
if git diff --name-only --cached | grep '/kubeapps/'; then
printf '\n\U1F6AB Commit cancelled\n\nKubeapps changes detected in this repository.\nPlease, implement them in the kubeapps repository (https://github.com/kubeapps/kubeapps/tree/master/chart/kubeapps).\n'
exit 1
fi
exit 0
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
if git diff --name-only --cached | grep '/upstreamed/'; then
printf '\n\U1F6AB Commit cancelled\n\nChanges detected in the "upstreamed" folder.\nPlease, implement them in the Helm Charts repository (https://github.com/helm/charts).\n'
exit 1
fi
exit 0
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
currentBranch="$(git rev-parse --abbrev-ref HEAD)"
originCommit="$(git rev-parse --short "$(git merge-base master "$currentBranch")")"
filesToBePushed="$(git diff --name-only "$originCommit")"
failed=0
for chartName in $( cut -d'/' -f1,2 <<< "$filesToBePushed" | uniq ); do
# Avoid running 'helm lint|install' when modified dirs are not charts
if [[ $chartName = bitnami/* ]]; then
printf '\033[01;33mValidating %s:\n\033[0m' "$chartName"
chartPath="$(git rev-parse --show-toplevel)"/"$chartName"
printf '\033[0;34m- Running helm lint %s\n\033[0m' "$chartPath"
if helm lint "$chartPath"; then
printf '\033[0;32m\U2705 helm lint %s\n\n\033[0m' "$chartPath"
else
printf '\033[0;31m\U1F6AB helm lint %s failed. Push cancelled.\n\n\033[0m' "$chartPath"
failed=1
fi
printf '\033\033[0;34m- Running helm install --dry-run %s\n\033[0m' "$chartPath"
helm repo add bitnami https://charts.bitnami.com/bitnami >> /dev/null
helm dependency update "$chartPath" >> /dev/null
if helm install --dry-run "$chartPath"; then
printf '\033[0;32m\U2705 helm install --dry-run %s\n\n\033[0m' "$chartPath"
else
printf '\033[0;31m\U1F6AB helm install --dry-run %s failed. Push cancelled.\n\n\033[0m' "$chartPath"
failed=1
fi
fi
done
exit $failed