2 # Generate debian/changelog.upstream from debian/changelog and
3 # the git revision log. Inspired by Gerrit Pape’s
4 # debian/changelog.upstream.sh, from the git-core Debian package.
8 # If argument matches /^Version: /, output remaining text.
9 # Result is true if and only if argument matches.
13 result
=${line#Version: }
15 if test "$result" = "$line"
19 printf "%s\n" "$result"
24 # If argument matches /^\* New.*snapshot.*commit /,
25 # output remaining text.
26 # Result is true if and only if argument matches.
30 result
=${line#\* New*snapshot*commit }
32 if test "$result" = "$line"
36 printf "%s\n" "$result"
41 # Read standard input, scanning for a changelog entry of the
42 # form “New snapshot, taken from upstream commit <blah>.”
44 # Fails and writes a message to standard error if no such entry is
45 # found before the next Version: line with a different upstream
47 # $1 is the upstream version sought.
49 local upstream_version line version cid
55 version
=$
(version_line
"$line") &&
56 test "${version%-*}" != "$upstream_version"
61 if cid
=$
(commit_id_line
"$line")
63 printf "%s\n" "${cid%.}"
68 echo >&2 "No commit id for $upstream_version"
74 # Add a list of all revisions up to $last to debian/changelog.upstream
76 # $1 is a user-readable name for the commit $2
78 local new new_cid limiter
82 if test "$last" = none
84 : > debian
/changelog.upstream
90 exec >> debian
/changelog.upstream
94 echo "Version $last:" |
tr "[:print:]" -
96 elif test "$new" = "$last"
100 echo "Version $last; changes since $new:"
101 echo "Version $last; changes since $new:" |
tr "[:print:]" -
105 git rev-list
--no-merges "$limiter$last_cid" |
106 git diff-tree
--date=iso
--stat --format=medium
--stdin
107 test "$new" = none ||
echo
113 dpkg-parsechangelog
--format rfc822
--all |
{
116 if version
=$
(version_line
"$line")
118 # strip Debian revision
119 upstream_version
=${version%-*}
121 if git rev-parse
--verify -q "v$upstream_version" > /dev
/null
124 add_version
"$upstream_version" "v$upstream_version"
127 cid
=$
(read_commit_id
"$upstream_version") ||
exit 1
128 add_version
"$upstream_version" "$cid"
132 add_version none none