[Intel-gfx] [maintainer-tools PATCH 3/7] dim: split out email parsing functions
Eric Engestrom
eric.engestrom at imgtec.com
Wed Aug 9 11:10:57 UTC 2017
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
dim | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/dim b/dim
index eaabcec43c8f..a656afa0d255 100755
--- a/dim
+++ b/dim
@@ -1958,6 +1958,16 @@ function dim_fixes
fi
}
+function email_get_address
+{
+ sed -e 's/.*<//' -e 's/>.*//' <<< "$1"
+}
+
+function email_get_name
+{
+ echo ${cc/<*/} | sed -e 's/[[:space:]]*$//' <<< "$1"
+}
+
function dim_add_missing_cc
{
if [ $(git cat-file -p HEAD | grep -cE ^parent) -ne 1 ]; then
@@ -1966,11 +1976,11 @@ function dim_add_missing_cc
fi
git show | scripts/get_maintainer.pl --email --norolestats --pattern-depth 1 | while read cc; do
- email="$(echo "$cc" | sed -e 's/.*<//' -e 's/>.*//')"
+ email="$(email_get_address "$cc")"
name=''
if echo "$cc" | grep -q '<'; then
- name="$(echo ${cc/<*/} | sed -e 's/[[:space:]]*$//')";
+ name="$(email_get_name "$cc")";
fi
# Don't add main mailing lists
@@ -1983,12 +1993,12 @@ function dim_add_missing_cc
# print out a 1 on success
matches=$(
git show -s | grep -i "^ Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read testcc; do
- testemail="$(echo "$testcc" | sed -e 's/.*<//' -e 's/>.*//')"
+ testemail="$(email_get_address "$testcc")"
if [ "$testemail" != "$email" ]; then
if [ -z "$name" ]; then continue; fi
- testname="$(echo ${testcc/<*/} | sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//')"
+ testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')"
if [ "$testname" != "$name" ]; then continue; fi
fi
--
Cheers,
Eric
More information about the Intel-gfx
mailing list