Browse code

Update the Travis GitHub username regex to match the GitHub username requirements

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/07/07 23:32:09
Showing 1 changed files
... ...
@@ -9,13 +9,22 @@ notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
9 9
 : ${adds:=0}
10 10
 : ${dels:=0}
11 11
 
12
+# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash"
13
+githubUsernameRegex='[a-zA-Z][a-zA-Z-]+'
14
+
15
+# https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md#sign-your-work
16
+dcoPrefix='Docker-DCO-1.1-Signed-off-by:'
17
+dcoRegex="^$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)> \\(github: ($githubUsernameRegex)\\)$"
18
+
19
+check_dco() {
20
+	grep -qE "$dcoRegex"
21
+}
22
+
12 23
 if [ $adds -eq 0 -a $dels -eq 0 ]; then
13 24
 	echo '0 adds, 0 deletions; nothing to validate! :)'
14 25
 elif [ -z "$notDocs" -a $adds -le 1 -a $dels -le 1 ]; then
15 26
 	echo 'Congratulations!  DCO small-patch-exception material!'
16 27
 else
17
-	dcoPrefix='Docker-DCO-1.1-Signed-off-by:'
18
-	dcoRegex="^$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)> \\(github: (\S+)\\)$"
19 28
 	commits=( $(validate_log --format='format:%H%n') )
20 29
 	badCommits=()
21 30
 	for commit in "${commits[@]}"; do
... ...
@@ -23,7 +32,7 @@ else
23 23
 			# no content (ie, Merge commit, etc)
24 24
 			continue
25 25
 		fi
26
-		if ! git log -1 --format='format:%B' "$commit" | grep -qE "$dcoRegex"; then
26
+		if ! git log -1 --format='format:%B' "$commit" | check_dco; then
27 27
 			badCommits+=( "$commit" )
28 28
 		fi
29 29
 	done