1 #!/bin/bash
3 # search for VERSIONS below to see how to change this when
4 # Kaldi's version number increases.
6 # Note: this script assumes that it's part of a git repository where
7 # the official kaldi repo is a remote named 'upstream', as shown
8 # here:
9 # git remote -vv | grep upstream
10 # upstream git@github.com:kaldi-asr/kaldi.git (fetch)
11 # upstream git@github.com:kaldi-asr/kaldi.git (push)
12 # Since Dan is going to be the one running this script and that's
13 # how he does it, this should work fine.
17 # the tuples are: <major/minor number> <branch on github> <first commit of that version>
19 if [ "$0" != "doc/get_version_info.sh" ] || [ $# -ne 0 ]; then
20 echo "$0: you should run this script without arguments, from the src/ directory."
21 echo "... It generates 5.0.html, 5.1.html, and so on."
22 fi
24 if ! git fetch upstream; then
25 echo "$0: command 'git fetch upstream' failed"
26 exit 1
27 fi
30 # echo "fooXXabcYYbar" | perl -ane ' if (m/XX(.+)YY/) { $a=$`;$x=$1;$y=$'\''; $x =~ s/a/b/g; print "${a}XX${x}YY${y}"; } else {print;}'
32 # VERSION
33 # When you increment the version of Kaldi you'll want to
34 # add a new tuple to the 'for' statement, of the form "5.x master yyyy".
35 # where the tuples will generally be of the form: "x.x master yyyyyy"
36 # where yyyyy is the result of git log -1 src/.version on
37 # that version of Kaldi (we only update the .version file when
38 # the major/minor version number changes).
39 # You should change the previous 'master' to the previous version number,
40 # e.g. 5.2 (this assumes you created a branch in Kaldi's repository that
41 # archives that version of Kaldi).
42 # Note: when you add new tuples here you'll also want to add ndew
43 # \htmlinclude directives in versions.dox.
46 for tuple in "5.0 5.0 c160a9883" "5.1 5.1 2145519961" "5.2 master 393ef73caa93"; do
47 major_minor_number=$(echo $tuple | awk '{print $1}') # e.g. 5.0
48 branch=$(echo $tuple | awk '{print $2}') # e.g. 'master', or '5.1' (it's a branch name)
49 first_commit=$(echo $tuple | awk '{print $3}')
52 tempfile=$(mktemp /tmp/temp.XXXXXX)
53 echo "$0: for version=$major_minor_number, writing git output to $tempfile"
55 patch_number=0
56 # git rev-list --reverse $first_commit..$branch lists the revisions from
57 # $first_commit to $branch... --boundary causes it to include $first_commit
58 # in the range, but with a dash (-) included for the first commit, so we
59 # use a sed command to get rid of that.
60 for rev in $(git rev-list --reverse $first_commit..upstream/$branch --boundary | sed s/-//); do
61 # %h is abbrev. commit hash, %H is long commit hash, %cd is the commit date,
62 # %%s is the one-line log message; x09 is tab.
63 # so we're printing "<patch-number> <short-commit> <long-commit> <commit-date> <commit-subject>"
64 # we'll later parse this and generate HTML.
65 pretty_str="${patch_number}%x09%h%x09%H%x09%cd%x09%s";
66 git log --date=short --pretty="$pretty_str" -1 $rev
67 patch_number=$[patch_number+1]
68 done > $tempfile
70 htmlfile=doc/$major_minor_number.html
71 echo "$0: for version=$major_minor_number, processing $tempfile to $htmlfile"
73 cat $tempfile | perl -e '
74 ($major_minor_number) = @ARGV;
75 while (<STDIN>) {
76 if (! m/^(\S+)\t(\S+)\t(\S+)\t(\S+)\t(.+)/) {
77 die "Could not parse line $_ in git output";
78 } else {
79 $patch_number = $1; $short_commit = $2; $long_commit = $3;
80 $commit_date = $4; $commit_subject = $5;
81 if ($commit_subject =~ m/\(#(\d+)\)\s*$/) {
82 $pull_request_number = $1;
83 $pre_match = $`; # part before what was matched.
84 $pre_match =~ s/</</g;
85 $pre_match =~ s/>/>/g;
86 # if commit subject line ends with e.g. (#1302), which will
87 # be a pull request; create a href to github for that.
88 $commit_subject = $pre_match .
89 "<a href=\"https://github.com/kaldi-asr/kaldi/pull/$pull_request_number\" target=\"_blank\">(#$pull_request_number)</a>";
90 } else {
91 $commit_subject =~ s/</</g;
92 $commit_subject =~ s/>/>/g;
93 }
94 $commit_href =
95 "<a href=\"https://github.com/kaldi-asr/kaldi/commit/$long_commit\" target=\"_blank\">$short_commit</a>";
96 $line = "$major_minor_number.$patch_number $commit_href $commit_date $commit_subject <br>\n";
97 print $line;
98 }
99 print "<p>\n";
100 } ' "$major_minor_number" >$htmlfile || exit 1
101 echo "$0: generated file $htmlfile with $(wc -l <$htmlfile) lines"
102 # you might want to comment the command below if you are debugging the script.
103 rm $tempfile
104 done