aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorziggys <ziggys@autistici.org>2018-06-10 18:04:51 -0400
committerziggys <ziggys@autistici.org>2018-06-10 18:04:51 -0400
commitf62927b489d27152734d01121246f32d96943c14 (patch)
treec3a20fc9934ea863fcea1b1d1898772f5d9f3dcd
parent36b40e1efce56ab3620cb565345ff181227d1481 (diff)
downloadgc2gs-f62927b489d27152734d01121246f32d96943c14.zip
gc2gs-f62927b489d27152734d01121246f32d96943c14.tar
Full syntax checkout
-rwxr-xr-xgc2gs.sh29
1 files changed, 15 insertions, 14 deletions
diff --git a/gc2gs.sh b/gc2gs.sh
index 62dcb00..746b0fb 100755
--- a/gc2gs.sh
+++ b/gc2gs.sh
@@ -16,7 +16,8 @@ LICENSE="The Drunken BEER License v 1.1 (https://git.p4g.club/git/beer/about)"
show_help () {
test $# = 0 || echo "$@"
echo "${SCRIPTNAME} version $VERSION"
-echo " License: "${LICENSE}""
+echo " by ${AUTHOR}"
+echo " License: ${LICENSE}"
echo
echo "${SCRIPTNAME} is a shellscript that posts a status message to a"
echo " gnu-social node with the last commit information of a git-project"
@@ -69,7 +70,7 @@ configure () {
printf "\\nPopulating %s...\\n" "${RCFILE}"
printf "USER=%s;\\nPASSWORD=%s;\\nNODE=%s;\\n" \
- "${CONFUNAME}" "${CONFPASS}" "${CONFNODE}" >> ${RCFILE}
+ "${CONFUNAME}" "${CONFPASS}" "${CONFNODE}" >> "${RCFILE}"
printf "PROJECT=%s;\\nPROJECTURL=%s;\\nREPOPATH=%s;\\nPLATFORM=%s;\\n" \
"${CONFPROJ}" "${CONFPURL}" "${REPOPATH}" "${CONFPLAT}" >> "${RCFILE}"
@@ -104,7 +105,7 @@ hook_config () {
# check if the repopath is a git repository
isgit () {
- cd ${REPOPATH}
+ cd "${REPOPATH}" || echo "${REPOPATH}" > /dev/null
git rev-parse > /dev/null
test "$?" -ne 0 \
&& printf "\\n%s is not a git repository, exiting..." "${REPOPATH}" \
@@ -128,7 +129,7 @@ test "${ANSFORCONFIG}" = "yes" && configure || exit 0
status_config () {
# project variables
- cd "${REPOPATH}"
+ cd "${REPOPATH}" || echo "${REPOPATH}" > /dev/null
BRANCH="$(git branch | sed '/^*/ !d; s/* //')"
COMMITMSG="$(git log -1 --pretty=%B)"
COMMITTER="$(git log -1 | sed '/Author:/ !d; s/Author: //; s/<*[ \t].*//')"
@@ -151,15 +152,15 @@ status_config () {
"${TTITLE}" "${BRANCH}" "${COMMITTER}" "${COMMITDATE}" >> "${TSTATUS}"
printf "%s (%s)\\n\\ncommit_url: %s\\n\\nproject_url: %s" \
"${COMMITMSG}" "${COMMITID}" "${COMMITURL}" "${PROJECTURL}" >> "${TSTATUS}"
- STATUS="$(cat ${TSTATUS})"
+ STATUS="$(cat "${TSTATUS}")"
}
# post
gs_post () {
status_config
# deobfuscate user and pass
- USER="$(echo ${USER} | base64 --decode -)"
- PASSWORD="$(echo ${PASSWORD} | base64 --decode -)"
+ USER="$(echo "${USER}" | base64 --decode -)"
+ PASSWORD="$(echo "${PASSWORD}" | base64 --decode -)"
PME="A status message was posted on ${NODE} by ${USER}"
NPME="An error ocurred posting on ${NODE}"
@@ -172,7 +173,7 @@ gs_post () {
# read options from commandline
test "$#" -lt 1 && show_help
-while getopts ":c:k:x:p:vh" opt; do
+while getopts ":c:k:p:vh" opt; do
case ${opt} in
c) CONFNAME="${OPTARG}" ; EXECUTE="config" ;;
k) CONFNAME="${OPTARG}" ; EXECUTE="hook" ;;
@@ -180,17 +181,17 @@ while getopts ":c:k:x:p:vh" opt; do
\?) printf "Invalid: -%s" "${OPTARG}" 1>&2 ; exit 3 ;;
:) printf "Invalid: -%s requires an argument" "${OPTARG}" 1>&2 ; exit 3 ;;
v) VERBOSE="notnull" ;;
- h) show_help ;;
+ h) show_help "${@}";;
esac
done
shift $((OPTIND -1))
# create temp files for operation
TMPDIR="$(mktemp -d)"
-CPREPUSH="$(mktemp -p ${TMPDIR})"
-INPUT="$(mktemp -p ${TMPDIR})"
-TSTATUS="$(mktemp -p ${TMPDIR})"
-VOUTPUT="$(mktemp -p ${TMPDIR})"
+CPREPUSH="$(mktemp -p "${TMPDIR}")"
+INPUT="$(mktemp -p "${TMPDIR}")"
+TSTATUS="$(mktemp -p "${TMPDIR}")"
+VOUTPUT="$(mktemp -p "${TMPDIR}")"
# configure variables
test -z "${CONFNAME}" && show_help
@@ -203,7 +204,7 @@ SNIPPET="snippet/snippet"
HOOKPATH=".git/hooks/pre-push"
# input variables
-sed '/^#/ d; s/;[ \t].*//g; s/;$//g; s/[ \t]*$//g' ${RCFILE} > "$INPUT"
+sed '/^#/ d; s/;[ \t].*//g; s/;$//g; s/[ \t]*$//g' "${RCFILE}" > "$INPUT"
USER="$(sed '/USER=/ !d; s/USER=//' "$INPUT")"
PASSWORD="$(sed '/PASSWORD=/ !d; s/PASSWORD=//' "$INPUT")"