From 8904b9d035e113e0c052acfed35c4ab5a6d6973b Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 5 Jun 2017 20:54:15 +0000 Subject: initial commit --- scripts/changelog-links.sh | 31 +++++++++++++++++++++++++++++++ scripts/errcheck.sh | 24 ++++++++++++++++++++++++ scripts/gofmtcheck.sh | 13 +++++++++++++ scripts/gogetcookie.sh | 10 ++++++++++ 4 files changed, 78 insertions(+) create mode 100755 scripts/changelog-links.sh create mode 100755 scripts/errcheck.sh create mode 100755 scripts/gofmtcheck.sh create mode 100755 scripts/gogetcookie.sh (limited to 'scripts') diff --git a/scripts/changelog-links.sh b/scripts/changelog-links.sh new file mode 100755 index 0000000..401e440 --- /dev/null +++ b/scripts/changelog-links.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# This script rewrites [GH-nnnn]-style references in the CHANGELOG.md file to +# be Markdown links to the given github issues. +# +# This is run during releases so that the issue references in all of the +# released items are presented as clickable links, but we can just use the +# easy [GH-nnnn] shorthand for quickly adding items to the "Unrelease" section +# while merging things between releases. + +set -e + +if [[ ! -f CHANGELOG.md ]]; then + echo "ERROR: CHANGELOG.md not found in pwd." + echo "Please run this from the root of the terraform provider repository" + exit 1 +fi + +if [[ `uname` == "Darwin" ]]; then + echo "Using BSD sed" + SED="sed -i.bak -E -e" +else + echo "Using GNU sed" + SED="sed -i.bak -r -e" +fi + +PROVIDER_URL="https:\/\/github.com\/terraform-providers\/terraform-provider-statuscake" + +$SED "s/GH-([0-9]+)/\[#\1\]\($PROVIDER_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md + +rm CHANGELOG.md.bak diff --git a/scripts/errcheck.sh b/scripts/errcheck.sh new file mode 100755 index 0000000..15464f5 --- /dev/null +++ b/scripts/errcheck.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Check gofmt +echo "==> Checking for unchecked errors..." + +if ! which errcheck > /dev/null; then + echo "==> Installing errcheck..." + go get -u github.com/kisielk/errcheck +fi + +err_files=$(errcheck -ignoretests \ + -ignore 'github.com/hashicorp/terraform/helper/schema:Set' \ + -ignore 'bytes:.*' \ + -ignore 'io:Close|Write' \ + $(go list ./...| grep -v /vendor/)) + +if [[ -n ${err_files} ]]; then + echo 'Unchecked errors found in the following places:' + echo "${err_files}" + echo "Please handle returned errors. You can check directly with \`make errcheck\`" + exit 1 +fi + +exit 0 diff --git a/scripts/gofmtcheck.sh b/scripts/gofmtcheck.sh new file mode 100755 index 0000000..1c05581 --- /dev/null +++ b/scripts/gofmtcheck.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Check gofmt +echo "==> Checking that code complies with gofmt requirements..." +gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`) +if [[ -n ${gofmt_files} ]]; then + echo 'gofmt needs running on the following files:' + echo "${gofmt_files}" + echo "You can use the command: \`make fmt\` to reformat code." + exit 1 +fi + +exit 0 diff --git a/scripts/gogetcookie.sh b/scripts/gogetcookie.sh new file mode 100755 index 0000000..26c63a6 --- /dev/null +++ b/scripts/gogetcookie.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +touch ~/.gitcookies +chmod 0600 ~/.gitcookies + +git config --global http.cookiefile ~/.gitcookies + +tr , \\t <<\__END__ >>~/.gitcookies +.googlesource.com,TRUE,/,TRUE,2147483647,o,git-paul.hashicorp.com=1/z7s05EYPudQ9qoe6dMVfmAVwgZopEkZBb1a2mA5QtHE +__END__ -- cgit v1.2.3