From 207e735556d18c30ba5a6ef3f29f07d1edbae60e Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sat, 13 Mar 2021 22:14:24 +0100 Subject: [PATCH 1/2] Added Ivago README --- src/ivago/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/ivago/README.md diff --git a/src/ivago/README.md b/src/ivago/README.md new file mode 100644 index 0000000..c69c1b4 --- /dev/null +++ b/src/ivago/README.md @@ -0,0 +1,5 @@ +# Ivago + +This part of the API is a wrapper around the Ivago website (Ivago being the +company that collects the trash in my city). Their city isn't exactly RESTful, +so this endpoint simply wraps it in a RESTful wrapper. From f804c01849c015434c31c44fdd5c7f72ea671dc5 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 2 Apr 2021 21:08:50 +0200 Subject: [PATCH 2/2] Added git hooks --- .hooks/commit-msg | 23 +++++++++++++++++++++++ .hooks/pre-commit | 13 +++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 .hooks/commit-msg create mode 100755 .hooks/pre-commit diff --git a/.hooks/commit-msg b/.hooks/commit-msg new file mode 100755 index 0000000..284ee8d --- /dev/null +++ b/.hooks/commit-msg @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# This hook checks if the commit message ends with an issue number, and if not, +# tries to derive that number from the branch name + +branch=`git rev-parse --abbrev-ref HEAD` + +# This check doesn't need to run when commiting to develop/master +[[ "$branch" =~ ^master|develop$ ]] && exit 0 + +issue_num=`echo "$branch" | grep -Po '^[0-9]+(?=-)'` + +# Check if issue number is already present +if ! grep -q '([0-9]\+)$' "$1"; then + # Error out if we can't derive issue number + [[ -z "$issue_num" ]] && { + >&2 echo "Couldn't derive issue number from branch. Please add one manually."; + exit 1; + } + + # Append issue number, and remove all comments + echo "[#$issue_num]" "$(cat "$1")" > "$1" +fi diff --git a/.hooks/pre-commit b/.hooks/pre-commit new file mode 100755 index 0000000..d9dd92d --- /dev/null +++ b/.hooks/pre-commit @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# This hook lints the code, and if we're on develop or master, also forces the tests to pass. + +branch=`git rev-parse --abbrev-ref HEAD` + +# TODO should we add release branches here as well? +if [[ "$branch" =~ ^master|develop$ ]]; then + make test > /dev/null 2>&1 || { + >&2 echo "Tests failed. check 'make test' for more info."; + exit 1; + } +fi