Skip to content

Commit

Permalink
chore: cleanup and minify code
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Aug 19, 2019
1 parent 64f827a commit 2712d1a
Showing 1 changed file with 10 additions and 33 deletions.
43 changes: 10 additions & 33 deletions please
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ FULL=`readlink -f $0` # fullpath
PLIZ=`basename $0` # name

line() { echo -e "\e[${3:-0};$2m$1\e[0m"; }

error() { line "$1" 31; }

error() { line "$1" 31; if [[ ! ${2:-0} -eq 0 ]]; then exit $2; fi }
ok() { line "${1:- Done}" 32; }

info() { line "$1" 33; }

comment() { line "$1" 30 1; }

qgit() { git "$@" &>> $TMP_LOG; }
Expand All @@ -31,14 +27,10 @@ qgit() { git "$@" &>> $TMP_LOG; }
github()
{
RESP=`bash -c "curl --silent -H 'Authorization: token $GH_AUTH_TOKEN' $@"`
echo "${RESP}" >> ${TMP_LOG}
echo "$RESP" >> ${TMP_LOG}

ERROR=`echo $RESP | jq -r '.message?'`

if [ "" != "$ERROR" ] && [ "null" != "$ERROR" ]; then
error "Github: $ERROR"
exit 1
fi
if [ "" != "$ERROR" ] && [ "null" != "$ERROR" ]; then error "Github: $ERROR" 1; fi

echo "$RESP"
}
Expand Down Expand Up @@ -98,19 +90,12 @@ EXAMPLE
organize-commits() # $1 = diff_range, $2 = commit_types_csv
{
declare -A LABELS=(
[feat]=Features
[fix]="Bug Fixes"
[refactor]="Internal Refactors"
[perf]="Performance Improvements"
[test]=Tests
[docs]=Documentations
[chore]=Miscellaneous
[style]="Code Standards"
[infra]="Infrastructure Changes"
[feat]=Features [fix]="Bug Fixes" [refactor]="Internal Refactors"
[perf]="Performance Improvements" [test]=Tests [docs]=Documentations
[chore]=Miscellaneous [style]="Code Standards" [infra]="Infrastructure Changes"
)

declare -A CHANGELOG

while read -r COMMIT; do
if [[ $COMMIT =~ ^([a-z]+)\(?([^\)]+)?\)?:\ (.+) ]]; then
type="${BASH_REMATCH[1]}" scope="${BASH_REMATCH[2]}" subject="${BASH_REMATCH[3]}"
Expand Down Expand Up @@ -175,15 +160,10 @@ publish-phar()
{
PBIN=`cat composer.json | jq -r '.bin[0]?'`
if [ "null" == "$PBIN" ]; then
error "Check bin value in composer.json"
info "Check ${TMP_LOG} for logs"
exit 1
error "Check bin value in composer.json" 1
fi
info "Cleaning up ..."
rm -rf ./vendor/cov
ok
info "Compiling phar ..."
php `get-box` compile >> ${TMP_LOG}
ok
Expand Down Expand Up @@ -268,8 +248,7 @@ do
done
if [ "" == "$REPO" ]; then
error "$(pwd) is not git repo"
exit 1
error "$(pwd) is not git repo" 1
fi
GPUSH=0 # git push pending
Expand All @@ -281,8 +260,7 @@ YES=${YES:-0} # assume yes
# gh auth
if [ -z "$GH_AUTH_TOKEN" ]; then
error "GH_AUTH_TOKEN missing"
exit 1
error "GH_AUTH_TOKEN missing" 1
fi
GH_REPO="github.com/repos/$REPO"
Expand Down Expand Up @@ -349,8 +327,7 @@ if [[ $YES -eq 0 ]]; then
read -p "Are you sure to release [$NEXT_VERSION]? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
error "Not releasing $NEXT_VERSION"
exit 1
error "Not releasing $NEXT_VERSION" 1
fi
fi
Expand Down

0 comments on commit 2712d1a

Please sign in to comment.