File: release-commit

package info (click to toggle)
bird2 2.17.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: ansic: 74,910; sh: 3,712; perl: 3,444; lex: 883; python: 495; makefile: 464; xml: 260; sed: 13
file content (84 lines) | stat: -rwxr-xr-x 2,084 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

set -e

toplevel=$(readlink -f $(dirname $0)/..)
current_version=$(<$toplevel/VERSION)

pushd $toplevel > /dev/null

# Enforce clean repository (we are going to commit!)
if [ $(git status --porcelain -uno | wc -l) != "0" ]; then
  echo "Dirty repository, commit or stash!"
  exit 1
fi

# Enforce no fixups and no WIPs
tools/git-check-commits

# Compute the new version
case $1 in
  patch)
    new_version=$(awk -F. 'OFS="." { $3+=1; print; }' <<<"$current_version")
    ;;
  minor)
    new_version=$(awk -F. 'OFS="." { $2+=1; if ($1 < 3) print $1,$2; else print $1,$2,0; }' <<<"$current_version")
    ;;
  *)
    echo "Usage: $0 (minor|patch)"
    echo "Commits the version update commit"
    exit 2
esac

file=$(mktemp)
news=$(mktemp)
function cleanup() {
  rm -f $file $news
}
trap cleanup EXIT ERR

# Prepare the NEWS file
echo "## Releasing version $new_version ##" >> $file
echo -n "########################" >> $file
sed 's/./#/g' <<<"$new_version" >> $file
echo >> $file
news_headline="Version $new_version ($(date +%F))"
echo $news_headline >> $file
git log --oneline v$current_version..HEAD | sed -r 's/^([^ ]+) (.*)/# commit \1\n  o \2/' >> $file
echo >> $file
echo "# Empty the file to cancel the commit." >> $file
echo "# Do not change the Version header." >> $file

# Edit the NEWS file
$(git var GIT_EDITOR) $file

# Collect the result
if ! egrep -v '^(#.*)?$' $file > $news; then
  echo "Release canceled"
  exit 1
fi

# Check whether the result is correct
if [ "$news_headline" != "$(head -n1 $news)" ]; then
  echo "Garbled headline, got $(head -n1 $news)"
  exit 1
fi

badlines=$(tail -n+2 $news | grep -v '^  [o ] ' | wc -l)
if [ "$badlines" != 0 ]; then
  echo "Garbled news file, offending lines:"
  tail -n+2 $news | grep -v '^  [o ] '
  exit 1
fi

# Do the changes in the repository: NEWS, bird.spec and VERSION
echo >> $news
cat NEWS >> $news
mv $news NEWS

sed -i "s/^Version: $current_version\$/Version: $new_version/" misc/bird.spec

echo $new_version > VERSION

# Commit!
git commit -m "NEWS and version update" -- NEWS VERSION misc/bird.spec