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
53 EMAIL="$(git config --get user.email)"
55 CHANGESFILE=$(ls package/*.changes)
56 test -f "$CHANGESFILE" || errexit "No changes file '$CHANGESFILE'"
58 VERSIONFILE="VERSION.cmake"
59 test -f "$VERSIONFILE" || errexit "No version file '$VERSIONFILE'"
61 function getversion() {
68 /^ *SET *\( *LIBZYPP_MAJOR *"[0-9]+" *\)/ {getnum();major=$0}
69 /^ *SET *\( *LIBZYPP_MINOR *"[0-9]+" *\)/ {getnum();minor=$0}
70 /^ *SET *\( *LIBZYPP_PATCH *"[0-9]+" *\)/ {getnum();patch=$0}
71 /^ *SET *\( *LIBZYPP_COMPATMINOR *"[0-9]+" *\)/ {getnum();compatminor=$0}
73 gsub("^.*RELEASED: *","");
76 gsub(".*\\(","",lastcompat)
77 gsub("\\).*","",lastcompat)
82 thisrelease = major"."minor"."patch" ("compatminor")"
83 printf "LAST_RELEASE='%s'\n", lastrelease
84 printf "LAST_COMPAT='%s'\n", lastcompat
85 printf "THIS_RELEASE='%s'\n", major"."minor"."patch
86 printf "THIS_COMPAT='%s'\n", compatminor
87 printf "THIS_MINOR='%s'\n", minor
88 printf "THIS_PATCH='%s'\n", patch
93 function setversion() {
96 sed -i "s/^ *SET *( *${KEY} .*/SET(${KEY} \"${VAL}\")/" "$VERSIONFILE"
99 function sameVersion() {
100 test "$LAST_RELEASE" == "$THIS_RELEASE" -a "$LAST_COMPAT" == "$THIS_COMPAT"
103 function getchanges() {
104 git log --no-merges --pretty=format:'- %s' "$LAST_RELEASE"..HEAD | grep -v 'po.tar.bz2'
107 function newchangesentry() {
108 echo "-------------------------------------------------------------------"
109 echo "$(date) - $EMAIL"
113 echo "- version $THIS_RELEASE ($THIS_COMPAT)"
118 function is_fast_forward() {
120 test "$(git rev-list HEAD..origin/$(git name-rev --name-only HEAD) --count)" == "0"
125 Recho "!!! Branch is not fast-forward. Pull changes first."
130 git status --porcelain | grep '^[^ ?]' | grep -v "$VERSIONFILE\|$CHANGESFILE" && {
131 Becho "!!! Files other than version and changes are added to the index."
132 Becho "!!! Doing dryrun..."
136 # A tag for $LAST_RELEASE must exist!
138 git rev-parse -q --verify "$LAST_RELEASE" >/dev/null || {
140 Recho "!!! There is no LAST_RELEASE tag '$LAST_RELEASE'. Check manually. "
141 Recho "!!! (git tag -m 'tagging $LAST_RELEASE' '$LAST_RELEASE' ?commit?)"
146 if [ "$DRYRUN" == "1" ]; then
149 Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
163 Becho "!!! Version is unchanged at $LAST_RELEASE ($LAST_COMPAT)."
164 read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (P) patch, (M) minor, (I) incompat minor, (e)dit version [e]: ")" RES
173 Becho "!!! Leave $VERSIONFILE untouched"
177 setversion LIBZYPP_PATCH $(($THIS_PATCH + 1))
182 setversion LIBZYPP_MINOR $(($THIS_MINOR + 1))
183 setversion LIBZYPP_PATCH 0
188 setversion LIBZYPP_COMPATMINOR $(($THIS_MINOR + 1))
189 setversion LIBZYPP_MINOR $(($THIS_MINOR + 1))
190 setversion LIBZYPP_PATCH 0
202 # prepare changes file
205 trap " [ -f \"$TMPFILE\" ] && /bin/rm -f -- \"$TMPFILE\" " 0 1 2 3 13 15
206 { newchangesentry; cat $CHANGESFILE; } >$TMPFILE
209 while [ "$RES" == "e" ]; do
212 awk '{print}/^----------/{n=n+1; if ( n == 2 ) exit 0; }' $TMPFILE
213 read -n 1 -p "$(Gecho "(a)bort, (c)ontinue, (s)ubmitt, (e)dit [e]: ")" RES
220 Becho "!!! Store new $CHANGESFILE"
221 mv $TMPFILE $CHANGESFILE
222 chmod 644 $CHANGESFILE
224 test "$RES" == "s" && {
225 if [ "$LAST_RELEASE" == "$THIS_RELEASE" ]; then
226 git add "$CHANGESFILE" && git commit -m "changes"
228 Becho "!!! Remember new version $THIS_RELEASE in $VERSIONFILE"
229 sed -i "s/^# LAST RELEASED:.*$/# LAST RELEASED: $THIS_RELEASE ($THIS_COMPAT)/" $VERSIONFILE
230 if git add "$CHANGESFILE" "$VERSIONFILE" \
231 && git commit -m "changes $THIS_RELEASE ($THIS_COMPAT)" \
232 && git tag -m "tagging $THIS_RELEASE" "$THIS_RELEASE" HEAD; then
234 Becho "!!! Do not forget to push the commit and the tag: $(Gecho git push --tags origin HEAD)"
238 Recho "!!! Commit failed. Check manually. (git reset HEAD~)"
246 Becho "!!! Leave $CHANGESFILE untouched"