You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2022/05/19 10:11:17 UTC
[isis] 01/02: ISIS-2900: adds gitcommit.sh utility script
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2900
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 194bd98346e80207a6c3ae64e3d273b7c46c8188
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu May 19 11:10:32 2022 +0100
ISIS-2900: adds gitcommit.sh utility script
---
gitcommit.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/gitcommit.sh b/gitcommit.sh
new file mode 100644
index 0000000000..6af2b0c791
--- /dev/null
+++ b/gitcommit.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+usage() {
+ echo "$(basename $0): [-A] [-P] message" >&2
+ echo " -A : suppress adding automatically, ie don't call 'git add .'" >&2
+ echo " -p : also push" >&2
+}
+
+PUSH=""
+ADD=""
+
+while getopts ":hAp" arg; do
+ case $arg in
+ h)
+ usage
+ exit 0
+ ;;
+ A)
+ ADD="no-add"
+ ;;
+ p)
+ PUSH="push"
+ ;;
+ *)
+ usage
+ exit 1
+ esac
+done
+
+if [ $# -lt 1 ];
+then
+ echo $USAGE >&2
+ exit 1
+fi
+
+shift $((OPTIND-1))
+
+ISSUE=$(git rev-parse --abbrev-ref HEAD | cut -d- -f1,2)
+MSG=$*
+
+echo "ISSUE : $ISSUE"
+echo "MSG : $MSG"
+echo "(NO-)ADD : $ADD"
+echo "PUSH : $PUSH"
+
+if [ -d _pipeline-resources ]
+then
+ pushd _pipeline-resources || exit
+ if [ -z "$ADD" ]
+ then
+ git add .
+ fi
+ git commit -m "$ISSUE: ${MSG}"
+ if [ -n "$PUSH" ]
+ then
+ git push
+ fi
+ popd || exit
+fi
+
+if [ -z "$ADD" ]
+then
+ git add .
+fi
+git commit -m "$ISSUE: ${MSG}"
+if [ -n "$PUSH" ]
+then
+ git push
+fi