fixed git-changelog plugin

pull/1816/head
Gurkirat Singh 2021-01-24 18:01:51 +05:30 committed by Noah Gorny
parent 63f9f660a9
commit 77654875e5
2 changed files with 272 additions and 275 deletions

View File

@ -50,6 +50,7 @@ themes/modern
plugins/available/basher.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash
plugins/available/docker-machine.plugin.bash
plugins/available/git.plugin.bash
plugins/available/go.plugin.bash
plugins/available/goenv.plugin.bash
plugins/available/history.plugin.bash

View File

@ -1,3 +1,5 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'git helper functions'
@ -57,11 +59,10 @@ function git_rollback() {
}
function keep_changes() {
while true
do
while true; do
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])
echo "Rolling back to commit ${1} with unstaged changes"
git reset $1
@ -74,6 +75,7 @@ function git_rollback() {
;;
*)
echo "Please enter Y or N"
;;
esac
done
}
@ -82,11 +84,10 @@ function git_rollback() {
is_clean
commit_exists $1
while true
do
while true; do
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])
keep_changes $1
break
@ -96,6 +97,7 @@ function git_rollback() {
;;
*)
echo "Please enter Y or N"
;;
esac
done
else
@ -180,8 +182,7 @@ function git_stats {
LOGOPTS="$LOGOPTS -C --find-copies-harder"
shift
fi
for a in $AUTHORS
do
for a in $AUTHORS; do
echo '-------------------'
echo "Statistics for: $a"
echo -n "Number of files changed: "
@ -212,7 +213,7 @@ function gittowork() {
echo "$result"
else
if [[ -f .gitignore ]]; then
result=`echo "$result" | grep -v "# Created by http://www.gitignore.io"`
result=$(echo "$result" | grep -v "# Created by http://www.gitignore.io")
echo ".gitignore already exists, appending..."
echo "$result" >> .gitignore
else
@ -237,24 +238,21 @@ function gitignore-reload() {
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --
then
if ! git diff-files --quiet --ignore-submodules --; then
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
# Disallow uncommited changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules
then
if ! git diff-index --cached --quiet HEAD --ignore-submodules; then
echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
# Prompt user to commit or stash changes and exit
if [ $err = 1 ]
then
if [ $err = 1 ]; then
echo >&2 "Please commit or stash them."
fi
@ -282,22 +280,20 @@ function git-changelog(){
group 'git'
example '$ git-changelog origin/master...origin/release [md|txt]'
if [[ "$1" != *"..."* ]]
then
if [[ "$1" != *"..."* ]]; then
echo "Please include the valid 'diff' to make changelog"
return 1
fi
local NEXT=$(date +%F)
if [[ "$2" == "md" ]]
then
if [[ "$2" == "md" ]]; then
echo "# CHANGELOG $1"
git log $1 --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo
echo "### $DATE"
GIT_PAGER=cat 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"
NEXT=$DATE
done
else
@ -306,7 +302,7 @@ function git-changelog(){
git log $1 --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo
echo [$DATE]
GIT_PAGER=cat 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"
NEXT=$DATE
done
fi