# ==================================================
#=======
-# - Update version according to your changes,
-# but based on 'LAST RELEASED:' below. I.e
-# there's no need to increase LIBZYPP_MINOR
-# if it already differs from 'LAST RELEASED:'.
-#
# - MOST IMPORTANT:
-# Before you submitt to autobuild, rmember the
-# new version in 'LAST RELEASED:', and add a
-# note in the changes file.
-#
-# - Consider calling ./mkChangelog to edit the
-# changes file. See './mkChangelog -h' for help.
+# - Before you submitt to git:
+# - Remember the new version in 'LAST RELEASED:'
+# - State the new version in the changes file by adding a line
+# "- version MAJOR.MINOR.PATCH (COMPATMINOR)"
+# - Commit changes and version files together in a separate
+# commit using -m 'changes MAJOR.MINOR.PATCH (COMPATMINOR)'
+# - Tag the above commit with 'MAJOR.MINOR.PATCH' using
+# -m "tagging MAJOR.
+#
+# - Consider calling ./mkChangelog to assist you.
+# See './mkChangelog -h' for help.
#
SET(LIBZYPP_MAJOR "10")
SET(LIBZYPP_COMPATMINOR "3")
#! /bin/bash
+function Recho() { echo -e "\e[0;31m""$@""\e[0m"; }
+function Gecho() { echo -e "\e[0;32m""$@""\e[0m"; }
+function Becho() { echo -e "\e[0;34m""$@""\e[0m"; }
+
function errexit() {
exec >&2
- echo "Error: $@"
+ Recho "Error: $@"
exit 1
}
Options:
-h,-?,--help This page.
+ -n Dryrun.
Prepare a new changes file entry preloaded with all commits since the last
changes tag and load it into \$EDITOR (vi). If the version file was changed,
exit 1
}
+DRYRUN=0
+
case "$1" in
+ -[n]*)
+ DRYRUN=1
+ ;;
-[hH?]*)
usage
;;
/^ *SET *\( *LIBZYPP_MINOR *"[0-9]+" *\)/ {getnum();minor=$0}
/^ *SET *\( *LIBZYPP_PATCH *"[0-9]+" *\)/ {getnum();patch=$0}
/^ *SET *\( *LIBZYPP_COMPATMINOR *"[0-9]+" *\)/ {getnum();compatminor=$0}
- /^# LAST RELEASED:/ {gsub("^.*RELEASED: *","");gsub(" +$","");gsub(" +\\(.*","");lastrelease=$0}
+ /^# LAST RELEASED:/ {
+ gsub("^.*RELEASED: *","");
+ gsub(" +$","");
+ lastcompat=$0
+ gsub(".*\\(","",lastcompat)
+ gsub("\\).*","",lastcompat)
+ gsub(" +\\(.*","");
+ lastrelease=$0
+ }
END {
thisrelease = major"."minor"."patch" ("compatminor")"
- gsub(" \\(.*","",lastrelease)
printf "LAST_RELEASE='%s'\n", lastrelease
+ printf "LAST_COMPAT='%s'\n", lastcompat
printf "THIS_RELEASE='%s'\n", major"."minor"."patch
printf "THIS_COMPAT='%s'\n", compatminor
}
'
}
-# $LAST_RELEASE
-# $THIS_RELEASE
-# $THIS_COMPAT
-eval $(getversion)
+function sameVersion() {
+ test "$LAST_RELEASE" == "$THIS_RELEASE" -a "$LAST_COMPAT" == "$THIS_COMPAT"
+}
+
+function getchanges() {
+ git log --no-merges --pretty=format:'- %s' "$LAST_RELEASE"..HEAD | grep -v 'po.tar.bz2'
+}
function newchangesentry() {
echo "-------------------------------------------------------------------"
echo "$(date) - $EMAIL"
echo ""
- echo "$(git log --no-merges --pretty=format:'- %s' "$LAST_RELEASE"..HEAD | grep -v 'po.tar.bz2')"
- test "$LAST_RELEASE" != "$THIS_RELEASE" && {
+ echo "$(getchanges)"
+ sameVersion || {
echo "- version $THIS_RELEASE ($THIS_COMPAT)"
}
echo ""
}
+
+git status --porcelain | grep '^[^ ]' | grep -v "$VERSIONFILE\|$CHANGESFILE" && {
+ Becho "!!! Files other than version and changes are added to the index."
+ Becho "!!! Doing dryrun..."
+ DRYRUN=1
+}
+if [ "$DRYRUN" == "1" ]; then
+ eval $(getversion)
+ newchangesentry
+ sameVersion && {
+ Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
+ }
+ exit 0
+fi
+
+
+# check version file
+#
+while true; do
+ # $LAST_RELEASE
+ # $LAST_COMPAT
+ # $THIS_RELEASE
+ # $THIS_COMPAT
+ eval $(getversion)
+ sameVersion && {
+ newchangesentry
+ Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
+ read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (e)dit version: ")" RES
+ echo
+ case "$RES" in
+ [eE]*)
+ $EDITOR $VERSIONFILE
+ continue
+ ;;
+ [cC])
+ Becho "!!! Leave $VERSIONFILE untouched"
+ break
+ ;;
+ *)
+ errexit "aborted"
+ ;;
+ esac
+ }
+ break
+done
+
+# prepare changes file
+#
TMPFILE=$(mktemp)
trap " [ -f \"$TMPFILE\" ] && /bin/rm -f -- \"$TMPFILE\" " 0 1 2 3 13 15
{ newchangesentry; cat $CHANGESFILE; } >$TMPFILE
$EDITOR $TMPFILE
echo
awk '{print}/^----------/{n=n+1; if ( n == 2 ) exit 0; }' $TMPFILE
- read -n 1 -p "(a)bort, (c)ontinue, (s)ubmitt, (e)dit : " RES
- echo
+ read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (s)ubmitt, (e)dit : ")" RES
echo
case "$RES" in
[eE]*)
RES=e
;;
[cCsS])
- echo "Store new $CHANGESFILE"
+ Becho "!!! Store new $CHANGESFILE"
mv $TMPFILE $CHANGESFILE
test "$RES" == "s" && {
if [ "$LAST_RELEASE" == "$THIS_RELEASE" ]; then
git add "$CHANGESFILE" && git commit -m "changes"
else
- echo "Remember new version $THIS_RELEASE in $VERSIONFILE"
+ Becho "!!! Remember new version $THIS_RELEASE in $VERSIONFILE"
sed -i "s/^# LAST RELEASED:.*$/# LAST RELEASED: $THIS_RELEASE ($THIS_COMPAT)/" $VERSIONFILE
git add "$CHANGESFILE" "$VERSIONFILE" \
- && git commit -m "changes $THIS_RELEASE" \
+ && git commit -m "changes $THIS_RELEASE ($THIS_COMPAT)" \
&& git tag -m "tagging $THIS_RELEASE" "$THIS_RELEASE" HEAD
- echo ""
- echo "Do not forget to push the commit and the tag: git push --tags"
- echo ""
+ Becho "!!!"
+ Becho "!!! Do not forget to push the commit and the tag: $(Gecho git push --tags)"
+ Becho "!!!"
fi
}
;;
*)
- echo "Leave $CHANGESFILE untouched"
+ Becho "!!! Leave $CHANGESFILE untouched"
;;
esac
done