added plugin to create git changelog and formatted code

pull/1816/head
Gurkirat Singh 2020-12-27 23:59:16 +05:30 committed by Noah Gorny
parent 1fbd91ebf9
commit 92d814b2f6
1 changed files with 238 additions and 203 deletions

View File

@ -160,10 +160,10 @@ function git_stats {
about 'display stats per author' about 'display stats per author'
group 'git' group 'git'
# 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' ')
@ -193,9 +193,9 @@ if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then
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"
fi fi
} }
function gittowork() { function gittowork() {
@ -273,3 +273,38 @@ function gitignore-reload() {
echo >&2 "Files readded. Commit your new changes now." echo >&2 "Files readded. Commit your new changes now."
fi fi
} }
function git-changelog(){
about 'Creates the git changelog from one point to another by date'
group 'git'
example '$ git-changelog origin/master...origin/release [md|txt]'
if [[ "$1" != *"..."* ]]
then
echo "Please include the valid 'diff' to make changelog"
return 1
fi
local NEXT=$(date +%F)
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"
NEXT=$DATE
done
else
echo "CHANGELOG $1"
echo ----------------------
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"
NEXT=$DATE
done
fi
}