fix (git): lint formatting in plugins

pull/2112/head
Gurkirat Singh 2022-03-07 11:36:49 +05:30
parent 6f1dcd1433
commit f543e768cd
No known key found for this signature in database
GPG Key ID: 5D829219EF259AA5
1 changed files with 36 additions and 34 deletions

View File

@ -43,7 +43,7 @@ function git_rollback() {
group 'git' group 'git'
function is_clean() { function is_clean() {
if [[ $(git diff --shortstat 2>/dev/null | tail -n1) != "" ]]; then if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo "Your branch is dirty, please commit your changes" echo "Your branch is dirty, please commit your changes"
kill -INT $$ kill -INT $$
fi fi
@ -62,24 +62,24 @@ function git_rollback() {
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
case "${RESP}" in case "${RESP}" in
[yY]) [yY])
echo "Rolling back to commit ${1} with unstaged changes" echo "Rolling back to commit ${1} with unstaged changes"
git reset "$1" git reset "$1"
break break
;; ;;
[nN]) [nN])
echo "Rolling back to commit ${1} with a clean working tree" echo "Rolling back to commit ${1} with a clean working tree"
git reset --hard "$1" git reset --hard "$1"
break break
;; ;;
*) *)
echo "Please enter Y or N" echo "Please enter Y or N"
;; ;;
esac esac
done done
} }
if [ -n "$(git symbolic-ref HEAD 2>/dev/null)" ]; then if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
is_clean is_clean
commit_exists "$1" commit_exists "$1"
@ -88,16 +88,16 @@ function git_rollback() {
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
case "${RESP}" in case "${RESP}" in
[yY]) [yY])
keep_changes "$1" keep_changes "$1"
break break
;; ;;
[nN]) [nN])
break break
;; ;;
*) *)
echo "Please enter Y or N" echo "Please enter Y or N"
;; ;;
esac esac
done done
else else
@ -117,7 +117,7 @@ function local-ignore() {
about 'adds file or path to git exclude file' about 'adds file or path to git exclude file'
param '1: file or path fragment to ignore' param '1: file or path fragment to ignore'
group 'git' group 'git'
echo "$1" >>.git/info/exclude echo "$1" >> .git/info/exclude
} }
# get a quick overview for your git repo # get a quick overview for your git repo
@ -125,7 +125,7 @@ function git_info() {
about 'overview for your git repo' about 'overview for your git repo'
group 'git' group 'git'
if [ -n "$(git symbolic-ref HEAD 2>/dev/null)" ]; then if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
# print informations # print informations
echo "git repo overview" echo "git repo overview"
echo "-----------------" echo "-----------------"
@ -140,7 +140,7 @@ function git_info() {
# print status of working repo # print status of working repo
echo "status:" echo "status:"
if [ -n "$(git status -s 2>/dev/null)" ]; then if [ -n "$(git status -s 2> /dev/null)" ]; then
git status -s git status -s
else else
echo "working directory is clean" echo "working directory is clean"
@ -165,7 +165,7 @@ function git_stats() {
# awesome work from https://github.com/esc/git-stats # awesome work from https://github.com/esc/git-stats
# including some modifications # including some modifications
if [ -n "$(git symbolic-ref HEAD 2>/dev/null)" ]; then if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
echo "Number of commits per author:" echo "Number of commits per author:"
git --no-pager shortlog -sn --all git --no-pager shortlog -sn --all
AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ') AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
@ -209,7 +209,7 @@ function gittowork() {
param '1: the language/type of the project, used for determining the contents of the .gitignore file' param '1: the language/type of the project, used for determining the contents of the .gitignore file'
example '$ gittowork java' example '$ gittowork java'
result=$(curl -L "https://www.gitignore.io/api/$1" 2>/dev/null) result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null)
if [[ "${result}" =~ ERROR ]]; then if [[ "${result}" =~ ERROR ]]; then
echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'" echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'"
@ -217,10 +217,10 @@ function gittowork() {
echo "${result}" echo "${result}"
else else
if [[ -f .gitignore ]]; then if [[ -f .gitignore ]]; then
result=$(grep -v "# Created by http://www.gitignore.io" <<<"${result}") result=$(grep -v "# Created by http://www.gitignore.io" <<< "${result}")
echo ".gitignore already exists, appending..." echo ".gitignore already exists, appending..."
fi fi
echo "${result}" >>.gitignore echo "${result}" >> .gitignore
fi fi
} }
@ -320,7 +320,9 @@ function git-get-default-branch() {
group 'git' group 'git'
example '$ git-get-default-branch' example '$ git-get-default-branch'
echo $(basename $(git symbolic-ref refs/remotes/origin/HEAD)) local BRANCH
BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD)
basename "$BRANCH"
} }
function git-delete-stale-branch() { function git-delete-stale-branch() {
@ -329,7 +331,7 @@ function git-delete-stale-branch() {
example '$ git-delete-stale-branch [--force|-f]' example '$ git-delete-stale-branch [--force|-f]'
local CURR_BRANCH local CURR_BRANCH
CURR_BRANCH=$(git branch | grep "*" | awk '{print $2}') CURR_BRANCH=$(git branch | grep "\*" | awk '{print $2}')
if [[ "$1" == "--force" ]] || [[ "$1" == "-f" ]]; then if [[ "$1" == "--force" ]] || [[ "$1" == "-f" ]]; then
git branch | grep -vE "$(git-get-default-branch)|$CURR_BRANCH" | xargs git branch -D git branch | grep -vE "$(git-get-default-branch)|$CURR_BRANCH" | xargs git branch -D