[maintainer-tools PATCH 6/7] dim: split out 'is email cc'ed in latest commit' to a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Eric Engestrom <eric.engestrom@xxxxxxxxxx>
---
 dim | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/dim b/dim
index 481a53e23035..2e22fefa8867 100755
--- a/dim
+++ b/dim
@@ -1970,6 +1970,31 @@ function email_get_name
 	fi
 }
 
+function email_cc_in_latest_commit
+{
+	email="$1"
+	name="$2"
+
+	git show -s | grep -i "^    Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read -r testcc; do
+		testemail="$(email_get_address "$testcc")"
+		testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')"
+
+		if [ "$testemail" = "$email" ]; then
+			return 1
+		fi
+
+		if [ -z "$testname" ] || [ -z "$name" ]; then
+			continue
+		fi
+
+		if [ "$testname" = "$name" ]; then
+			return 1
+		fi
+	done || return 0
+
+	return 1
+}
+
 function dim_add_missing_cc
 {
 	if [ $(git cat-file -p HEAD | grep -cE ^parent) -ne 1 ]; then
@@ -1987,26 +2012,7 @@ function dim_add_missing_cc
 			continue
 		fi
 
-		# Variables from the while loop don't propagate,
-		# print out a 1 on success
-		matches=$(
-			git show -s | grep -i "^    Cc:" | sed 's/^ *[Cc][Cc]: *//' | while read testcc; do
-				testemail="$(email_get_address "$testcc")"
-
-				if [ "$testemail" != "$email" ]; then
-					if [ -z "$name" ]; then continue; fi
-
-					testname="$(email_get_name "$testcc" | sed -e 's/^[[:space:]]*//')"
-
-					if [ "$testname" != "$name" ]; then continue; fi
-				fi
-
-				echo 1
-				break
-			done
-		)
-
-		if [ -z "$matches" ]; then
+		if ! email_cc_in_latest_commit "$email" "$name"; then
 			$DRY dim_commit_add_tag "Cc: ${cc}"
 		fi
 	done
-- 
Cheers,
  Eric

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux