From 8bb14ec909855ea47e1e610b16096218ccfa98e1 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Thu, 18 Apr 2019 21:02:06 +0200 Subject: [PATCH] add pre-push hook --- README.md | 2 +- README.txt | 8 ++++---- bashbot.cron | 2 +- bashbot.rc | 2 +- bashbot.sh | 2 +- calc | 2 +- commands.sh | 2 +- doc/1_firstbot.md | 2 +- doc/2_usage.md | 2 +- doc/3_advanced.md | 2 +- doc/4_expert.md | 2 +- doc/5_practice.md | 2 +- doc/6_reference.md | 2 +- {test => hooks}/install-hooks.sh | 4 ++-- {test => hooks}/pre-commit.sh | 2 +- hooks/pre-push.sh | 31 +++++++++++++++++++++++++++++++ {test => hooks}/shellcheck.files | 4 ++-- notify | 2 +- question | 2 +- version | 2 +- 20 files changed, 55 insertions(+), 24 deletions(-) rename {test => hooks}/install-hooks.sh (82%) rename {test => hooks}/pre-commit.sh (92%) create mode 100755 hooks/pre-push.sh rename {test => hooks}/shellcheck.files (80%) diff --git a/README.md b/README.md index 52a856b..1837bbc 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,4 @@ Bashbot is not more (in)secure as any other Bot written in any other language, w If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/README.txt b/README.txt index 8efb506..847a550 100644 --- a/README.txt +++ b/README.txt @@ -17,8 +17,8 @@ Prerequisites Depends on http://github.com/tmux/tmux[tmux]. Uses http://github.com/dominictarr/JSON.sh[JSON.sh]. -For full UTF-8 support you need -link:doc/4_expert.md#UTF-8-Support[python on your system] (optional). +Most complete link:doc/4_expert.md#Bashbot-UTF-8-Support[UTF-8 support +for bashbot] is availible if phyton is installed (optional). Bashbot https://github.com/topkecleon/telegram-bot-bash[Documentation] and https://github.com/topkecleon/telegram-bot-bash/releases[Downloads] @@ -161,5 +161,5 @@ That's it! If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -latexmath:[\[VERSION\]] v0.60-0-gf5162e2 -++++++++++++++++++++++++++++++++++++++++ +latexmath:[\[VERSION\]] 0.70-dev-2-gebd9e6f ++++++++++++++++++++++++++++++++++++++++++++ diff --git a/bashbot.cron b/bashbot.cron index e5aa77e..651191a 100644 --- a/bashbot.cron +++ b/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f SHELL=/bin/sh diff --git a/bashbot.rc b/bashbot.rc index 58deb15..4712ff0 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 8376553..59e15ea 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,7 +10,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # # Exit Codes: # - 0 sucess (hopefully) diff --git a/calc b/calc index b35eb40..b1c026b 100755 --- a/calc +++ b/calc @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/commands.sh b/commands.sh index 7c3f0fa..34dc980 100755 --- a/commands.sh +++ b/commands.sh @@ -4,7 +4,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # # shellcheck disable=SC2154 # shellcheck disable=SC2034 diff --git a/doc/1_firstbot.md b/doc/1_firstbot.md index 4fe1822..614ca9d 100644 --- a/doc/1_firstbot.md +++ b/doc/1_firstbot.md @@ -61,5 +61,5 @@ group. This step is up to you actually. #### [Next Getting started](2_usage.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/doc/2_usage.md b/doc/2_usage.md index cfd993d..0c03389 100644 --- a/doc/2_usage.md +++ b/doc/2_usage.md @@ -159,5 +159,5 @@ send_action "${CHAT[ID]}" "action" #### [Prev Create Bot](1_firstbot.md) #### [Next Advanced Usage](3_advanced.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/doc/3_advanced.md b/doc/3_advanced.md index 48155e8..24ceee7 100644 --- a/doc/3_advanced.md +++ b/doc/3_advanced.md @@ -156,5 +156,5 @@ answer_inline_query "$iQUERY_ID" "cached_sticker" "identifier for the sticker" #### [Prev Advanced Usage](3_advanced.md) #### [Next Expert Use](4_expert.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/doc/4_expert.md b/doc/4_expert.md index 67391da..711c201 100644 --- a/doc/4_expert.md +++ b/doc/4_expert.md @@ -104,5 +104,5 @@ An example crontab is provided in ```bashbot.cron```. #### [Prev Expert Use](4_expert.md) #### [Next Best Practice](5_practice.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/doc/5_practice.md b/doc/5_practice.md index b24b577..974a535 100644 --- a/doc/5_practice.md +++ b/doc/5_practice.md @@ -112,5 +112,5 @@ The second warning is about an unused variable, this is true because in our exam #### [Prev Best Practice](5_practice.md) #### [Next Functions Reference](6_reference.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/doc/6_reference.md b/doc/6_reference.md index 5419742..580dc37 100644 --- a/doc/6_reference.md +++ b/doc/6_reference.md @@ -347,5 +347,5 @@ Send Input from Telegram to waiting Interactive Chat. #### [Prev Best Practice](5_practice.md) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f diff --git a/test/install-hooks.sh b/hooks/install-hooks.sh similarity index 82% rename from test/install-hooks.sh rename to hooks/install-hooks.sh index 93fd1cf..d3dc2c2 100755 --- a/test/install-hooks.sh +++ b/hooks/install-hooks.sh @@ -12,9 +12,9 @@ echo -n "Installing hooks..." for hook in pre-commit pre-push do rm -f "$GIT_DIR/hooks/${hook}" - if [ -f "test/${hook}.sh" ]; then + if [ -f "hooks/${hook}.sh" ]; then echo -n " $hook" - ln -s "../../test/${hook}.sh" "$GIT_DIR/hooks/${hook}" + ln -s "../../hooks/${hook}.sh" "$GIT_DIR/hooks/${hook}" fi done echo " Done!" diff --git a/test/pre-commit.sh b/hooks/pre-commit.sh similarity index 92% rename from test/pre-commit.sh rename to hooks/pre-commit.sh index 29bebc0..2c6afd4 100755 --- a/test/pre-commit.sh +++ b/hooks/pre-commit.sh @@ -18,7 +18,7 @@ echo "............................" unset IFS; set -f # run shellcheck before commit -FILES=$(sed '/^#/d' <"test/shellcheck.files") +FILES=$(sed '/^#/d' <"hooks/shellcheck.files") if [ "$FILES" != "" ]; then # shellcheck disable=SC2086 shellcheck -x ${FILES} diff --git a/hooks/pre-push.sh b/hooks/pre-push.sh new file mode 100755 index 0000000..686c9d4 --- /dev/null +++ b/hooks/pre-push.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +#### $$VERSION$$ 0.70-dev-0-g209c4b3 + +# magic to ensure that we're always inside the root of our application, +# no matter from which directory we'll run script +GIT_DIR=$(git rev-parse --git-dir) +cd "$GIT_DIR/.." || exit 1 +REMOTEVER="$(git ls-remote -t --refs 2>/dev/null | tail -1 | sed 's/.*\/v//')" +VERSION="$(git describe --tags | sed -e 's/-.*//' -e 's/v//')" + +echo "Running pre-push hook" + +# if any command inside script returns error, exit and return that error +set -e + +# let's fake failing test for now +echo "Running tests" +echo "............................" + +unset IFS; set -f + +# LOCAL version must greater than latest REMOTE release version +if (( $(echo "${VERSION} > ${REMOTEVER}" | bc -l) )); then + # update version in bashbot files on push + ./version +else + echo "Error: local version ${VERSION} must be greater than latest release version." + echo "use \"git tag ...\" to create a local version greater than ${REMOTEVER}" + exit 1 +fi + diff --git a/test/shellcheck.files b/hooks/shellcheck.files similarity index 80% rename from test/shellcheck.files rename to hooks/shellcheck.files index a3174ed..57a57a2 100644 --- a/test/shellcheck.files +++ b/hooks/shellcheck.files @@ -10,5 +10,5 @@ commands.sh notify question # test files -test/install-hooks.sh -test/pre-commit.sh +hooks/install-hooks.sh +hooks/pre-commit.sh diff --git a/notify b/notify index 56da2ac..71cc88b 100755 --- a/notify +++ b/notify @@ -2,7 +2,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/question index c1dc69b..8a53443 100755 --- a/question +++ b/question @@ -3,7 +3,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) -#### $$VERSION$$ v0.60-0-gf5162e2 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/version b/version index 9b2ce51..4a4325d 100755 --- a/version +++ b/version @@ -1,6 +1,6 @@ #!/bin/bash # -#### $$VERSION$$ 0.70-dev-0-g209c4b3 +#### $$VERSION$$ 0.70-dev-2-gebd9e6f # shellcheck disable=SC2016 # # Easy Versioning in git: