3 SED
=$
(which gsed
2>/dev
/null
); SED
=${SED:-sed}
7 local default
="${2:-n}"
11 printf "%s y/n [%s] > " "$prompt" "$default"
13 case "${input:-$default}" in
22 mkdir
"pwclient.get.$$"
27 rmdir "pwclient.get.$$"
31 date +"%a, %d %b %Y %H:%M:%S %z" |
$SED -e 's|, 0|, |'
39 for line
in $
($SED -ne '/^Subject: */ { s/^Subject: *//p; :next; n; s/^ \+//p; t next; b }' "$1"); do
40 subject
="$subject$line"
43 printf "%s\n" "$subject" |
$SED -e 's/^\[.*\] \+//'
54 for addr
in $
($SED -ne "/^$field: */ { s/^$field: *//p; :next; n; s/^ \\+//p; t next; b }" "$file"); do
55 list
="${list:+$list, }$(echo "$addr" | $SED -e 's/^ \+//; s/ \+$//')"
58 [ -n "$list" ] && printf "%s: %s\n" "$field" "$list"
62 $SED -ne "s/^$2: *//p" "$1" |
head -n1
66 local remote_ref remote_url remote_host remote_host remote_repo remote_user
68 remote_ref
="$(git for-each-ref --format='%(push:short)' $(git symbolic-ref -q HEAD))"
70 [ -n "$remote_ref" ] || \
71 remote_ref
="$(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD))"
73 [ -n "$remote_ref" ] || \
76 remote_url
="$(git remote get-url "${remote_ref%%/*}")"
80 remote_host
="${remote_url##http*://}"
81 case "$remote_host" in *@
*)
82 remote_user
="${remote_host%%@*}"
83 remote_host
="${remote_host##*@}"
85 case "$remote_host" in */*)
86 remote_repo
="${remote_host#*/}"
87 remote_host
="${remote_host%%/*}"
91 remote_host
="$remote_url"
92 case "$remote_host" in *@
*)
93 remote_user
="${remote_host%%@*}"
94 remote_host
="${remote_host##*@}"
96 case "$remote_host" in *:*)
97 remote_repo
="${remote_host##*:}"
98 remote_host
="${remote_host%%:*}"
103 case "$remote_host" in
104 git.openwrt.org|git.lede-project.org
)
105 case "$remote_repo" in
106 source.git|openwrt
/openwrt.git
)
107 echo "Merged into ${remote_ref##*/}."
109 lede
/*/staging.git|openwrt
/staging
/*.git
)
110 echo "Merged into my staging tree."
113 echo "Merged into ${remote_repo:-the repository}, branch ${remote_ref##*/}."
126 echo "$1" |
grep -sqE '^[0-9]+$' ||
{
127 echo "Usage: $0 <patch-id>" >&2
131 [ -f "$1.patch" ] ||
{
132 pwclient info
"$1" >/dev
/null
2>/dev
/null ||
{
133 echo "Unknown patch ID: $1" >&2
138 echo "Failed to download patch" >&2
143 git am
"$1.patch" ||
{
144 echo "Failed to apply patch $1" >&2
151 if ! yesno
"Keep change?" "y"; then
152 git
reset --hard HEAD^
154 if yesno
"Set to 'Changes Requested'?"; then
155 pwclient update
-s "Changes Requested" "$1"
158 if yesno
"Set to 'Accepted'?" "y"; then
159 pwclient update
-s "Accepted" "$1"
161 if yesno
"Send reply mail?" "y"; then
163 printf "From: %s <%s>\n" "$(git config user.name)" "$(git config user.email)"
165 get_hdr_list
"$1.patch" Cc
167 printf "Date: %s\n" "$(get_date)"
168 printf "Subject: Merged: %s\n\n" "$(get_subject "$1.
patch")"
177 if yesno
"Edit reply?" "n"; then
179 --to "$(get_hdr "$1.
patch" To)" \
180 --cc "$(get_hdr "$1.
patch" From)" \
181 --in-reply-to "$(get_hdr "$1.
patch" Message-Id)" \
185 --to "$(get_hdr "$1.
patch" To)" \
186 --cc "$(get_hdr "$1.
patch" From)" \
187 --in-reply-to "$(get_hdr "$1.
patch" Message-Id)" \
188 --confirm=never
"$1.reply"
191 rm -f "$1.reply" "$1.patch"