DEV Community

Discussion on: 10 More Git Tricks That You Should Know

Collapse
 
vimmer9 profile image
Damir Franusic

I use the following scripts to generate some common files. Although they work, you will probably need to tweak them to meet your needs.

CHANGELOG

#!/bin/bash
git log  --decorate --tags --no-walk > CHANGELOG 2>&1 || { echo "git repository not found!" > CHANGELOG; }

VERSION

#!/bin/bash

# Tag revisions like this:
# $ git tag -a -m "Version 0.2" v0.2 HEAD

VF=VERSION
DEFAULT_VERSION=v1.0

LF='
'
TAG_TYPE="v*"

# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -d .git -o -f .git &&
    VN=$(git describe --abbrev=4 --long --match=$TAG_TYPE HEAD 2>/dev/null) &&
    case "$VN" in
    *$LF*) (exit 1) ;;
    v[0-9]*)
        git update-index -q --refresh
        test -z "$(git diff-index --name-only HEAD --)" ||
        VN="$VN-mod" ;;
    esac
then
        continue
    #VN=$(echo "$VN" | sed -e 's/-/./g');
else
    VN="$DEFAULT_VERSION"
fi

#VN=$(expr "$VN" : v*'\(.*\)')

# Show the version to the user via stderr
echo >&2 "$VN"

# Parse the existing VERSION-FILE 
if test -r $VF
then
    VC=$(sed -e 's/^version: //' <$VF)
else
    VC=unset
fi

# If version has changed, update VERSION-FILE
test "$VN" = "$VC" || {
    echo "$VN" >$VF
    echo >&2 "($VF updated)"
}

AUTHORS

#!/bin/bash
echo -e "Original Author\n===============\nDamir Franusic <damir.franusic@gmail.com>" > AUTHORS
CONTRIBUTORS=`git log --format='%aN <%aE>' | sort -f | uniq | grep -v "Damir Franusic"`
if [ ! -z "$CONTRIBUTORS" ]; then
    echo -e "\nContributors\n============\n$CONTRIBUTORS" >> AUTHORS
fi
Collapse
 
jacobherrington profile image
Jacob Herrington (he/him)

Wow! Thanks for sharing 👌