fixed linting for `plugins/available/git.plugin.bash` file

pull/1816/head
Gurkirat Singh 2021-01-24 18:14:35 +05:30 committed by Noah Gorny
parent 77654875e5
commit 5cb52fa239
1 changed files with 24 additions and 19 deletions

View File

@ -4,11 +4,11 @@ cite about-plugin
about-plugin 'git helper functions' about-plugin 'git helper functions'
function git_remote { function git_remote {
about 'adds remote $GIT_HOSTING:$1 to current repo' about "adds remote $GIT_HOSTING:$1 to current repo"
group 'git' group "git"
echo "Running: git remote add origin ${GIT_HOSTING}:$1.git" echo "Running: git remote add origin ${GIT_HOSTING}:$1.git"
git remote add origin $GIT_HOSTING:$1.git git remote add origin "$GIT_HOSTING:$1".git
} }
function git_first_push { function git_first_push {
@ -25,15 +25,15 @@ function git_pub() {
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Publishing ${BRANCH} to remote origin" echo "Publishing ${BRANCH} to remote origin"
git push -u origin $BRANCH git push -u origin "$BRANCH"
} }
function git_revert() { function git_revert() {
about 'applies changes to HEAD that revert all changes after this commit' about 'applies changes to HEAD that revert all changes after this commit'
group 'git' group 'git'
git reset $1 git reset "$1"
git reset --soft HEAD@{1} git reset --soft "HEAD@{1}"
git commit -m "Revert to ${1}" git commit -m "Revert to ${1}"
git reset --hard git reset --hard
} }
@ -50,7 +50,7 @@ function git_rollback() {
} }
function commit_exists() { function commit_exists() {
git rev-list --quiet $1 git rev-list --quiet "$1"
status=$? status=$?
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then
echo "Commit ${1} does not exist" echo "Commit ${1} does not exist"
@ -60,17 +60,18 @@ function git_rollback() {
function keep_changes() { function keep_changes() {
while true; do while true; do
# shellcheck disable=SC2162
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
;; ;;
*) *)
@ -82,14 +83,15 @@ function git_rollback() {
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"
while true; do while true; do
# shellcheck disable=SC2162
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])
@ -133,8 +135,8 @@ function git_info() {
# print all remotes and thier details # print all remotes and thier details
for remote in $(git remote show); do for remote in $(git remote show); do
echo $remote: echo "$remote":
git remote show $remote git remote show "$remote"
echo echo
done done
@ -186,13 +188,13 @@ function git_stats {
echo '-------------------' echo '-------------------'
echo "Statistics for: $a" echo "Statistics for: $a"
echo -n "Number of files changed: " echo -n "Number of files changed: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f3 | sort -iu | wc -l git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l
echo -n "Number of lines added: " echo -n "Number of lines added: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f1 | awk '{s+=$1} END {print s}' git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}'
echo -n "Number of lines deleted: " echo -n "Number of lines deleted: "
git log $LOGOPTS --all --numstat --format="%n" --author=$a | cut -f2 | awk '{s+=$1} END {print s}' git log "$LOGOPTS" --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}'
echo -n "Number of merges: " echo -n "Number of merges: "
git log $LOGOPTS --all --merges --author=$a | grep -c '^commit' git log "$LOGOPTS" --all --merges --author="$a" | grep -c '^commit'
done done
else else
echo "you're currently not in a git repository" echo "you're currently not in a git repository"
@ -290,7 +292,8 @@ function git-changelog() {
if [[ "$2" == "md" ]]; then if [[ "$2" == "md" ]]; then
echo "# CHANGELOG $1" echo "# CHANGELOG $1"
git log $1 --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do # shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo echo
echo "### $DATE" echo "### $DATE"
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="$DATE 00:00:00" --until="$DATE 24:00:00" git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
@ -299,7 +302,9 @@ function git-changelog() {
else else
echo "CHANGELOG $1" echo "CHANGELOG $1"
echo ---------------------- echo ----------------------
git log $1 --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
# shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo echo
echo [$DATE] echo [$DATE]
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="$DATE 00:00:00" --until="$DATE 24:00:00" git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="$DATE 00:00:00" --until="$DATE 24:00:00"