[PATCH 3/4] trivial: Standardize variable naming in scripts
Stephen Finucane
stephen at that.guru
Tue Jan 31 10:01:44 AEDT 2017
Just so we can interact with them as expected.
Signed-off-by: Stephen Finucane <stephen at that.guru>
---
patchwork/bin/parsemail-batch.sh | 4 ++--
patchwork/bin/parsemail.sh | 5 +++++
tools/patchwork-update-commits | 8 ++++----
tools/post-receive.hook | 13 ++++++-------
4 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/patchwork/bin/parsemail-batch.sh b/patchwork/bin/parsemail-batch.sh
index bee047e..8536791 100755
--- a/patchwork/bin/parsemail-batch.sh
+++ b/patchwork/bin/parsemail-batch.sh
@@ -19,7 +19,7 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-PATCHWORK_BINDIR=$(dirname "$0")
+BIN_DIR=$(dirname "$0")
if [ $# -lt 1 ]; then
echo "usage: $0 <dir> [options]" >&2
@@ -40,5 +40,5 @@ shift
find "$mail_dir" -maxdepth 1 |
while read -r line; do
echo "$line"
- "$PATCHWORK_BINDIR/parsemail.sh" "$@" < "$mail_dir/$line"
+ "$BIN_DIR/parsemail.sh" "$@" < "$mail_dir/$line"
done
diff --git a/patchwork/bin/parsemail.sh b/patchwork/bin/parsemail.sh
index a742f60..5d1672e 100755
--- a/patchwork/bin/parsemail.sh
+++ b/patchwork/bin/parsemail.sh
@@ -22,6 +22,11 @@
BIN_DIR=$(dirname "$0")
PATCHWORK_BASE=$(readlink -e "$BIN_DIR/../..")
+if [ $# -lt 1 ]; then
+ echo "usage: $0 <file> [options]" >&2
+ exit 1
+fi
+
if [ -z "$PW_PYTHON" ]; then
PW_PYTHON=python2
fi
diff --git a/tools/patchwork-update-commits b/tools/patchwork-update-commits
index 257819e..c84a630 100755
--- a/tools/patchwork-update-commits
+++ b/tools/patchwork-update-commits
@@ -19,8 +19,8 @@
# along with Patchwork; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-toolsdir="$(dirname "$0")"
-pwpath="${toolsdir}/../patchwork"
+TOOLS_DIR="$(dirname "$0")"
+PW_DIR="${TOOLS_DIR}/../patchwork"
if [ "$#" -lt 1 ]; then
echo "usage: $0 <revspec>" >&2
@@ -29,6 +29,6 @@ fi
git rev-list --reverse "$@" |
while read -r commit; do
- hash=$(git diff "$commit~..$commit" | python "$pwpath/hasher.py")
- "$pwpath/bin/pwclient" update -s Accepted -c "$commit" -h "$hash"
+ hash=$(git diff "$commit~..$commit" | python "$PW_DIR/hasher.py")
+ "$PW_DIR/bin/pwclient" update -s Accepted -c "$commit" -h "$hash"
done
diff --git a/tools/post-receive.hook b/tools/post-receive.hook
index c29b221..8098ce8 100755
--- a/tools/post-receive.hook
+++ b/tools/post-receive.hook
@@ -21,37 +21,36 @@
# Git post-receive hook to update Patchwork patches after Git pushes
set -eu
+PW_DIR=/opt/patchwork/patchwork
+
#TODO: the state map should really live in the repo's git-config
STATE_MAP="refs/heads/master:Accepted"
-#
+
# ignore all commits already present in these refs
# e.g.,
# EXCLUDE="refs/heads/upstream refs/heads/other-project"
-#
EXCLUDE=""
-PWDIR=/opt/patchwork/patchwork
-
do_exit=0
trap "do_exit=1" INT
get_patchwork_hash() {
local hash
- hash=$(git diff "$1~..$1" | python $PWDIR/hasher.py)
+ hash=$(git diff "$1~..$1" | python $PW_DIR/hasher.py)
echo "$hash"
test -n "$hash"
}
get_patch_id() {
local id
- id=$($PWDIR/bin/pwclient info -h "$1" 2>/dev/null \
+ id=$($PW_DIR/bin/pwclient info -h "$1" 2>/dev/null \
| sed -rne 's,- id[[:space:]]*: ,,p')
echo "$id"
test -n "$id"
}
set_patch_state() {
- $PWDIR/bin/pwclient update -s "$2" -c "$3" "$1" 2>&1
+ $PW_DIR/bin/pwclient update -s "$2" -c "$3" "$1" 2>&1
}
update_patches() {
--
2.9.3
More information about the Patchwork
mailing list