5 local default
="${2:-n}"
9 printf "%s y/n [%s] > " "$prompt" "$default"
11 case "${input:-$default}" in
20 mkdir
"pwclient.get.$$"
25 rmdir "pwclient.get.$$"
29 date +"%a, %d %b %Y %H:%M:%S %z" |
sed -e 's|, 0|, |'
37 for line
in $
(sed -ne '/^Subject: */ { s/^Subject: *//p; :next; n; s/^ \+//p; t next; b }' "$1"); do
38 subject
="$subject$line"
41 printf "%s\n" "$subject" |
sed -e 's/^\[.*\] \+//'
52 for addr
in $
(sed -ne "/^$field: */ { s/^$field: *//p; :next; n; s/^ \\+//p; t next; b }" "$file"); do
53 list
="${list:+$list, }$(echo "$addr" | sed -e 's/^ \+//; s/ \+$//')"
56 [ -n "$list" ] && printf "%s: %s\n" "$field" "$list"
60 sed -ne "s/^$2: *//p" "$1" |
head -n1
64 local remote_ref remote_url remote_host remote_host remote_repo remote_user
66 remote_ref
="$(git for-each-ref --format='%(push:short)' $(git symbolic-ref -q HEAD))"
68 [ -n "$remote_ref" ] || \
69 remote_ref
="$(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD))"
71 [ -n "$remote_ref" ] || \
74 remote_url
="$(git remote get-url "${remote_ref%%/*}")"
78 remote_host
="${remote_url##http*://}"
79 case "$remote_host" in *@
*)
80 remote_user
="${remote_host%%@*}"
81 remote_host
="${remote_host##*@}"
83 case "$remote_host" in */*)
84 remote_repo
="${remote_host#*/}"
85 remote_host
="${remote_host%%/*}"
89 remote_host
="$remote_url"
90 case "$remote_host" in *@
*)
91 remote_user
="${remote_host%%@*}"
92 remote_host
="${remote_host##*@}"
94 case "$remote_host" in *:*)
95 remote_repo
="${remote_host##*:}"
96 remote_host
="${remote_host%%:*}"
101 case "$remote_host" in
102 git.openwrt.org|git.lede-project.org
)
103 case "$remote_repo" in
104 source.git|openwrt
/openwrt.git
)
105 echo "Merged into ${remote_ref##*/}."
107 lede
/*/staging.git|openwrt
/staging
/*.git
)
108 echo "Merged into my staging tree."
111 echo "Merged into ${remote_repo:-the repository}, branch ${remote_ref##*/}."
124 echo "$1" |
grep -sqE '^[0-9]+$' ||
{
125 echo "Usage: $0 <patch-id>" >&2
129 [ -f "$1.patch" ] ||
{
130 pwclient info
"$1" >/dev
/null
2>/dev
/null ||
{
131 echo "Unknown patch ID: $1" >&2
136 echo "Failed to download patch" >&2
141 git am
"$1.patch" ||
{
142 echo "Failed to apply patch $1" >&2
149 if ! yesno
"Keep change?" "y"; then
150 git
reset --hard HEAD^
152 if yesno
"Set to 'Changes Requested'?"; then
153 pwclient update
-s "Changes Requested" "$1"
156 if yesno
"Set to 'Accepted'?" "y"; then
157 pwclient update
-s "Accepted" "$1"
159 if yesno
"Send reply mail?" "y"; then
161 printf "From: %s <%s>\n" "$(git config user.name)" "$(git config user.email)"
163 get_hdr_list
"$1.patch" Cc
165 printf "Date: %s\n" "$(get_date)"
166 printf "Subject: Merged: %s\n\n" "$(get_subject "$1.
patch")"
175 if yesno
"Edit reply?" "n"; then
177 --to "$(get_hdr "$1.
patch" To)" \
178 --cc "$(get_hdr "$1.
patch" From)" \
179 --in-reply-to "$(get_hdr "$1.
patch" Message-Id)" \
183 --to "$(get_hdr "$1.
patch" To)" \
184 --cc "$(get_hdr "$1.
patch" From)" \
185 --in-reply-to "$(get_hdr "$1.
patch" Message-Id)" \
186 --confirm=never
"$1.reply"
189 rm -f "$1.reply" "$1.patch"