From 4f52455fc443b34604de0fe55a616aa94a998afd Mon Sep 17 00:00:00 2001 From: Mike Marchetti Date: Thu, 22 Mar 2018 13:54:44 -0400 Subject: [PATCH] update generation in case no tag is found Signed-off-by: Mike Marchetti --- tools/generatechangelog-pipeline.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tools/generatechangelog-pipeline.sh b/tools/generatechangelog-pipeline.sh index e2fa55e4..e4aae94f 100755 --- a/tools/generatechangelog-pipeline.sh +++ b/tools/generatechangelog-pipeline.sh @@ -1,19 +1,27 @@ #!/bin/bash REPO_NAME=$(basename $(git config --get remote.origin.url) | cut -d'.' -f1) +git pull --tags origin master &> /dev/null + +echo "

$REPO_NAME Changelog

" # get the latest tag TAG_START=$(git tag | sort -Vr | head -1) -head_tag_diff=$(git rev-list $TAG_START ^HEAD |wc -l) -if [ $head_tag_diff -eq 0 ]; then - # HEAD and latest tag intersect. Instead try and find a previous tag and use that as the start diff - TAG_END=$TAG_START - TAG_START=$(git tag | sort -Vr | head -2 | sort -V | head -1) +# check to see if there is a tag start first. +if [ ! -z "${TAG_START}" ]; then + head_tag_diff=$(git rev-list HEAD ^${TAG_START} |wc -l) + if [ $head_tag_diff -eq 0 ]; then + # HEAD and latest tag intersect. Instead try and find a previous tag and use that as the start diff + TAG_END=$TAG_START + TAG_START=$(git tag | sort -Vr | head -2 | sort -V | head -1) + else + TAG_END="HEAD" + fi + + echo "

tag: ${TAG_START} -> ${TAG_END}

" + git log --pretty=format:"
  • %h • %s
  • " --reverse ${TAG_START}..${TAG_END} else - TAG_END="HEAD" + # no tag, just give the full log + git log --pretty=format:"
  • %h • %s
  • " --reverse fi -git pull --tags origin master &> /dev/null -echo "

    $REPO_NAME Changelog

    " -echo "

    tag: ${TAG_START} -> ${TAG_END}

    " -git log --pretty=format:"
  • %h • %s
  • " --reverse ${TAG_START}..${TAG_END} -- 2.25.1