Merge ~paride/curtin:drop-new-upstream-snapshot into curtin:master

Proposed by Paride Legovini
Status: Merged
Approved by: Dan Watkins
Approved revision: 6df232f0e5d23aa602a7cd2bd6c908800d31e875
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~paride/curtin:drop-new-upstream-snapshot
Merge into: curtin:master
Diff against target: 178 lines (+0/-172)
1 file modified
dev/null (+0/-172)
Reviewer Review Type Date Requested Status
Dan Watkins (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+391359@code.launchpad.net

Commit message

Drop tools/new-upstream-snapshot

It's just an older version of the new-upstream-snapshot script
maintained in the uss-tableflip repository [1].

[1] https://github.com/canonical/uss-tableflip

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/tools/new-upstream-snapshot b/tools/new-upstream-snapshot
0deleted file mode 1007550deleted file mode 100755
index 6b50979..0000000
--- a/tools/new-upstream-snapshot
+++ /dev/null
@@ -1,172 +0,0 @@
1#!/bin/sh
2# This file is part of curtin. See LICENSE file for copyright and license info.
3
4TEMP_D=""
5CR='
6'
7error() { echo "$@" 1>&2; }
8fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
9Usage() {
10cat <<EOF
11${0##*/} [branch]
12 update current branch with trunk branch.
13 branch defaults to 'master'
14EOF
15}
16
17print_commit() {
18 local subject="$1" author="$2" bugs="$3" aname="" abugs=""
19 local indent=" - " indent2=" " ll=79
20 aname=${author% <*}
21 [ "${aname}" = "Scott Moser" ] && aname=""
22 abugs="${aname:+ [${aname}]}${bugs:+ (LP: ${bugs})}"
23 if [ $((${#subject}+${#abugs})) -le $(($ll-${#indent})) ]; then
24 echo "${indent}${subject}${abugs}"
25 elif [ ${#subject} -ge $(($ll-${#indent})) ]; then
26 echo "${subject}${abugs}" |
27 fmt --width=$(($ll-${#indent})) |
28 sed -e "1s/^/${indent}/; 1n;" \
29 -e 's/^[ ]*//' \
30 -e '/^[ ]*$/d' -e "s/^/$indent2/" -e 's/[ ]\+$//'
31
32 else
33 ( echo "${subject}"; echo "${abugs}" ) |
34 fmt --width=$(($ll-${#indent})) |
35 sed -e "1s/^/${indent}/; 1n;" \
36 -e 's/^[ ]*//' \
37 -e '/^[ ]*$/d' -e "s/^/$indent2/" -e 's/[ ]\+$//'
38 fi
39}
40
41git_log_to_dch() {
42 local line="" commit="" lcommit="" bugs=""
43 while :; do
44 read line || break
45 case "$line" in
46 commit\ *)
47 if [ -n "$commit" ]; then
48 print_commit "$subject" "$author" "$bugs"
49 fi
50 commit=${line#*: }
51 bugs=""
52 author=""
53 subject=""
54 ;;
55 Author:*) author="${line#Author: }";;
56 LP:*) bugs="${bugs:+${bugs}, }${line#*: }";;
57 "") [ -z "$subject" ] && read subject;;
58 esac
59 done
60 if [ -n "$commit" ]; then
61 print_commit "$subject" "$author" "$bugs"
62 fi
63}
64cleanup() {
65 [ ! -d "${TEMP_D}" ] || rm -Rf "${TEMP_D}"
66}
67
68from_ref=${1:-"master"}
69cur_branch=$(git rev-parse --abbrev-ref HEAD) ||
70 fail "failed to get current branch"
71
72case "$cur_branch" in
73 ubuntu/*) :;;
74 *) fail "You are on branch '$cur_branch', expect to be on ubuntu/*";;
75esac
76
77TEMP_D=$(mktemp -d) || fail "failed mktemp"
78trap cleanup EXIT
79
80prev_pkg_ver=$(dpkg-parsechangelog --show-field Version) ||
81 fail "failed reading package version"
82pkg_name=$(dpkg-parsechangelog --show-field Source) ||
83 fail "failed to read Source from changelog"
84
85merge_base=$(git merge-base "$from_ref" HEAD) ||
86 fail "cannot find merge base for $from_ref and HEAD"
87
88new_pkg_debian="0ubuntu1"
89new_upstream_ver=$(git describe --abbrev=8 "${from_ref}")
90new_pkg_ver="${new_upstream_ver}-${new_pkg_debian}"
91
92prev_upstream_ver=${prev_pkg_ver%-*}
93if [ "${prev_upstream_ver}" = "${new_upstream_ver}" ]; then
94 echo "nothing to commit. '$from_ref' is at ${new_upstream_ver}."
95 exit 0
96fi
97
98dpseries="debian/patches/series"
99if [ -e $dpseries ]; then
100 drops=""
101 while read bname extra; do
102 case "$bname" in
103 cpick-*)
104 commit=${bname#cpick-}
105 commit=${commit%%-*}
106 echo "bname=$bname commit=${commit}" 1>&2
107 if git merge-base --is-ancestor "$commit" "$from_ref"; then
108 drops="${drops} debian/patches/$bname"
109 fi
110 ;;
111 *) echo "$bname${extra:+ ${extra}}";;
112 esac
113 done < $dpseries > "${TEMP_D}/series"
114 drops=${drops# }
115 if [ -n "$drops" ]; then
116 cp "${TEMP_D}/series" "$dpseries" ||
117 fail "failed copying to $dpseries"
118 if [ ! -s $dpseries ]; then
119 git rm --force "$dpseries" ||
120 fail "failed removing empty $dpseries: git rm $dpseries"
121 fi
122 msg="drop cherry picks before merge from ${from_ref} at $new_upstream_ver"
123 msg="$msg${CR}${CR}drop the following cherry picks:"
124 for file in $drops; do
125 git rm "$file" || fail "failed to git rm $file"
126 msg="${msg}$CR $file"
127 done
128 git commit -m "$msg" "$dpseries" $drops
129 fi
130fi
131
132git merge "${from_ref}" -m "merge from $from_ref at $new_upstream_ver" ||
133 fail "failed: git merge ${from_ref} -m 'merge from $from_ref ..'"
134clog="${TEMP_D}/changelog"
135gitlog="${TEMP_D}/gitlog"
136
137git log --first-parent --no-decorate --format=full \
138 "${merge_base}..${from_ref}" > "$gitlog" ||
139 fail "failed git log ${merge_base}..${from_ref}"
140
141cat >> "$clog" <<EOF
142$pkg_name ($new_pkg_ver) UNRELEASED; urgency=medium
143
144 * New upstream snapshot.
145EOF
146git_log_to_dch < "$gitlog" >> "$clog" ||
147 fail "failed git_log_to_dch"
148cat >> "$clog" <<EOF
149
150 -- ${DEBFULLNAME} <$DEBEMAIL> $(date -R)
151
152EOF
153
154cat "$clog" "debian/changelog" > "$TEMP_D/newlog" &&
155 cp "$TEMP_D/newlog" "debian/changelog" ||
156 fail "failed replacing debian/changelog"
157
158dch -e || fail "dch -e exited $?"
159
160git diff
161
162echo -n "Commit this change? (Y/n): "
163read answer || fail "failed to read answer"
164case "$answer" in
165 n|[Nn][oO]) exit 1;;
166esac
167
168msg="update changelog (new upstream snapshot $new_upstream_ver)."
169git commit -m "$msg" debian/changelog ||
170 fail "failed to commit '$msg'"
171
172# vi: ts=4 expandtab syntax=sh

Subscribers

People subscribed via source and target branches