3 function Recho() { echo -e "\e[0;31m""$@""\e[0m"; }
4 function Gecho() { echo -e "\e[0;32m""$@""\e[0m"; }
5 function Becho() { echo -e "\e[0;34m""$@""\e[0m"; }
17 $(basename $0) [OPTIONS]
20 -h,-?,--help This page.
23 Prepare a new changes file entry preloaded with all commits since the last
24 changes tag and load it into \$EDITOR (vi). If the version file was changed,
25 optionally submitt and tag the new changes. Otherwise simply leave the changes
28 Don't forgett to push created tags as well: git push --tags
56 sed -i 's/ \+$//' "$FILE"
59 EMAIL="$(git config --get user.email)"
61 CHANGESFILE=$(ls package/*.changes)
62 test -f "$CHANGESFILE" || errexit "No changes file '$CHANGESFILE'"
64 VERSIONFILE="VERSION.cmake"
65 test -f "$VERSIONFILE" || errexit "No version file '$VERSIONFILE'"
67 function getversion() {
74 /^ *SET *\( *LIBZYPP_MAJOR *"[0-9]+" *\)/ {getnum();major=$0}
75 /^ *SET *\( *LIBZYPP_MINOR *"[0-9]+" *\)/ {getnum();minor=$0}
76 /^ *SET *\( *LIBZYPP_PATCH *"[0-9]+" *\)/ {getnum();patch=$0}
77 /^ *SET *\( *LIBZYPP_COMPATMINOR *"[0-9]+" *\)/ {getnum();compatminor=$0}
79 gsub("^.*RELEASED: *","");
82 gsub(".*\\(","",lastcompat)
83 gsub("\\).*","",lastcompat)
88 thisrelease = major"."minor"."patch" ("compatminor")"
89 printf "LAST_RELEASE='%s'\n", lastrelease
90 printf "LAST_COMPAT='%s'\n", lastcompat
91 printf "THIS_RELEASE='%s'\n", major"."minor"."patch
92 printf "THIS_COMPAT='%s'\n", compatminor
93 printf "THIS_MINOR='%s'\n", minor
94 printf "THIS_PATCH='%s'\n", patch
99 function setversion() {
102 sed -i "s/^ *SET *( *${KEY} .*/SET(${KEY} \"${VAL}\")/" "$VERSIONFILE"
105 function sameVersion() {
106 test "$LAST_RELEASE" == "$THIS_RELEASE" -a "$LAST_COMPAT" == "$THIS_COMPAT"
109 function getchanges() {
110 git log --no-merges --pretty=format:'@@%B' "$LAST_RELEASE"..HEAD \
111 | awk '/^@@/{p=1}/^@@Translated using Weblate/{p=0}(p){print}' \
112 | sed '/./{H;$!d};x;/./{s/ *\n */ /g;s/^ *//;s/ *$//;/[^]})!?:.]$/s/$/./;p};d' \
113 | fold -s -w 66 | sed '/^@@/{s/^../- /;p;d};s/^/ /'
116 function newchangesentry() {
117 echo "-------------------------------------------------------------------"
118 echo "$(date) - $EMAIL"
122 echo "- version $THIS_RELEASE ($THIS_COMPAT)"
127 function is_fast_forward() {
129 test "$(git rev-list HEAD..origin/$(git name-rev --name-only HEAD) --count)" == "0"
134 Recho "!!! Branch is not fast-forward. Pull changes first."
139 git status --porcelain | grep '^[^ ?]' | grep -v "$VERSIONFILE\|$CHANGESFILE" && {
140 Becho "!!! Files other than version and changes are added to the index."
141 Becho "!!! Doing dryrun..."
145 # A tag for $LAST_RELEASE must exist!
147 git rev-parse -q --verify "$LAST_RELEASE" >/dev/null || {
149 Recho "!!! There is no LAST_RELEASE tag '$LAST_RELEASE'. Check manually. "
150 Recho "!!! (git tag -m 'tagging $LAST_RELEASE' '$LAST_RELEASE' ?commit?)"
155 if [ "$DRYRUN" == "1" ]; then
158 Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
172 Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
173 read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (P) patch, (M) minor, (I) incompat minor, (e)dit version [e]: ")" RES
182 Becho "!!! Leave $VERSIONFILE untouched"
186 setversion LIBZYPP_PATCH $(($THIS_PATCH + 1))
191 setversion LIBZYPP_MINOR $(($THIS_MINOR + 1))
192 setversion LIBZYPP_PATCH 0
197 setversion LIBZYPP_COMPATMINOR $(($THIS_MINOR + 1))
198 setversion LIBZYPP_MINOR $(($THIS_MINOR + 1))
199 setversion LIBZYPP_PATCH 0
211 # prepare changes file
214 trap " [ -f \"$TMPFILE\" ] && /bin/rm -f -- \"$TMPFILE\" " 0 1 2 3 13 15
215 { newchangesentry; cat $CHANGESFILE; } >$TMPFILE
218 while [ "$RES" == "e" ]; do
221 awk '{print}/^----------/{n=n+1; if ( n == 2 ) exit 0; }' $TMPFILE
222 read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (s)ubmitt, (e)dit [e]: ")" RES
229 Becho "!!! Store new $CHANGESFILE"
230 mv $TMPFILE $CHANGESFILE
231 chmod 644 $CHANGESFILE
233 test "$RES" == "s" && {
234 if [ "$LAST_RELEASE" == "$THIS_RELEASE" ]; then
235 git add "$CHANGESFILE" && git commit -m "changes"
237 Becho "!!! Remember new version $THIS_RELEASE in $VERSIONFILE"
238 sed -i "s/^# LAST RELEASED:.*$/# LAST RELEASED: $THIS_RELEASE ($THIS_COMPAT)/" $VERSIONFILE
239 if git add "$CHANGESFILE" "$VERSIONFILE" \
240 && git commit -m "changes $THIS_RELEASE ($THIS_COMPAT)" \
241 && git tag -m "tagging $THIS_RELEASE" "$THIS_RELEASE" HEAD; then
243 Becho "!!! Do not forget to push the commit and the tag: $(Gecho git push --tags origin HEAD)"
247 Recho "!!! Commit failed. Check manually. (git reset HEAD~)"
255 Becho "!!! Leave $CHANGESFILE untouched"