X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=tools%2Fgeneratechangelog-pipeline.sh;h=e4aae94f7bc4b8a480939ced763b7d942f9d18bd;hb=a07a5abab74746876e0a2fd30838814cad6dc267;hp=83a767a74222d1282fdd50da338ac559b3267756;hpb=3a0fc42d6a01912debb9e8fbcff8a89d111ded72;p=osm%2Fdevops.git
diff --git a/tools/generatechangelog-pipeline.sh b/tools/generatechangelog-pipeline.sh
index 83a767a7..e4aae94f 100755
--- a/tools/generatechangelog-pipeline.sh
+++ b/tools/generatechangelog-pipeline.sh
@@ -1,10 +1,27 @@
#!/bin/bash
REPO_NAME=$(basename $(git config --get remote.origin.url) | cut -d'.' -f1)
-# get the latest tag
-TAG_END="HEAD"
-TAG_START=$(git tag | sort -Vr | head -1)
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}
+# get the latest tag
+TAG_START=$(git tag | sort -Vr | 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
+ # no tag, just give the full log
+ git log --pretty=format:" %h • %s " --reverse
+fi
+