2 #-------------------------------------------------------------------------------
4 # | ____| _| |_ / __ \ /\ | \/ |
5 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
6 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
7 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
8 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
10 # FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
13 # Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
16 # This file is part of FreeFOAM.
18 # FreeFOAM is free software: you can redistribute it and/or modify it
19 # under the terms of the GNU General Public License as published by the
20 # Free Software Foundation, either version 3 of the License, or (at your
21 # option) any later version.
23 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 # You should have received a copy of the GNU General Public License
29 # along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
32 # updateChangeLog [-h|--help] [-s|--since <version>] <version>
35 # Updates the ChangeLog file with data from the GIT log.
38 # --help Print a help message
40 # --since <version> Instead of searching the latest annotated tag
41 # beginning with a `v', use the history since tag
43 # <version> The version to mention in the heading.
45 #------------------------------------------------------------------------------
50 updateChangeLog [options] <version>
52 Generates entries in the ChangeLog file for version <version> with data from
53 the GIT version control.
55 The --since <version> option requires that a git tree-ish object with the name
56 v<version> exists (i.e. a tag named e.g. v0.1.0).
58 s,since= Consider history since v<version> tag instead of latest v* tag."
60 .
"$(git --exec-path)/git-sh-setup"
68 while [ $# -gt 0 ]; do
82 if [ -z "$VERSION" ]; then
83 die
"Version argument is required"
86 if ! [ -w "$FILE" ]; then
87 die
"The file '$FILE' does not exist or is not writeable"
90 if [ -z "$SINCE" ]; then
91 SINCE
="$(git describe --match 'v[0-9].[0-9].[0-9]*' --abbrev=0 2>/dev/null)"
93 if [ $stat -ne 0 ]; then
94 die
"Failed to find latest annotated tag matching 'v[0-9].[0-9].[0-9]*'"
98 # determine whether SINCE is an ancestor of HEAD
99 git merge-base
"$SINCE" HEAD
>/dev
/null
2>&1 || \
100 die
"Tag v$SINCE does not exist or is not an ancestor of HEAD"
102 echo "Updating $FILE with changes from $SINCE to $VERSION"
104 # write log entries to a temporary file
107 trap 'rm -f $tmp1 $tmp2 2>/dev/null; exit 0' EXIT TERM INT
108 git shortlog
-w --format='* %s' "$SINCE"..HEAD | \
109 grep -v 'Merge branch' |
sed 's|[0-9]):$|&:|' > "$tmp1"
113 /^Changes in {project}/ && dosub {
114 header = "Changes in {project} '$VERSION'";
116 print gensub(/./, "-", "g", header);
117 system("cat '$tmp1'");
120 {print $0}' $FILE > $tmp2
124 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file