Browse Source

Add check to naughty-commits to ensure that referenced commit exists in the upstream GitFetch branch

Also update single-line library files to rfc2822 format to avoid 'refs/heads/*'
Joe Ferguson 4 years ago
parent
commit
a6b189f0c5
3 changed files with 53 additions and 23 deletions
  1. 6 3
      library/sourcemage
  2. 19 11
      library/thrift
  3. 28 9
      naughty-commits.sh

+ 6 - 3
library/sourcemage

@@ -1,4 +1,7 @@
-# maintainer: Vlad Glagolev <[email protected]> (@vaygr)
+Maintainers: Vlad Glagolev <[email protected]> (@vaygr)
+GitRepo: git://github.com/vaygr/docker-sourcemage
+GitFetch: refs/heads/dist-stable
 
-latest: git://github.com/vaygr/docker-sourcemage@a03bbe3ae7bbb839c3c69afd4504ca336f7b9cb9 stable
-0.62: git://github.com/vaygr/docker-sourcemage@a03bbe3ae7bbb839c3c69afd4504ca336f7b9cb9 stable
+Tags: latest, 0.62
+GitCommit: a03bbe3ae7bbb839c3c69afd4504ca336f7b9cb9
+Directory: stable

+ 19 - 11
library/thrift

@@ -1,11 +1,19 @@
-# maintainer: Adam Hawkins <[email protected]> (@ahawkins)
-
-0.9: git://github.com/ahawkins/docker-thrift@d322572f7dd6ea468a14a4d832fbec26f152c71e 0.9
-0.9.3: git://github.com/ahawkins/docker-thrift@d322572f7dd6ea468a14a4d832fbec26f152c71e 0.9
-0.10: git://github.com/ahawkins/docker-thrift@e1f81dfe3e8fac5588e12d2b880166d1743dbecd 0.10
-0.10.0: git://github.com/ahawkins/docker-thrift@e1f81dfe3e8fac5588e12d2b880166d1743dbecd 0.10
-0.11: git://github.com/ahawkins/docker-thrift@00e197d889426695446baec4e034b5ddbb15bcb3 0.11
-0.11.0: git://github.com/ahawkins/docker-thrift@00e197d889426695446baec4e034b5ddbb15bcb3 0.11
-0.12: git://github.com/ahawkins/docker-thrift@d7e73876549d205898b1922bcbf69e74ef11c288 0.12
-0.12.0: git://github.com/ahawkins/docker-thrift@d7e73876549d205898b1922bcbf69e74ef11c288 0.12
-latest: git://github.com/ahawkins/docker-thrift@d7e73876549d205898b1922bcbf69e74ef11c288 0.12
+Maintainers: Adam Hawkins <[email protected]> (@ahawkins)
+GitRepo: git://github.com/ahawkins/docker-thrift
+GitFetch: refs/heads/master
+
+Tags: 0.9, 0.9.3
+GitCommit: d322572f7dd6ea468a14a4d832fbec26f152c71e
+Directory: 0.9
+
+Tags: 0.10, 0.10.0
+GitCommit: e1f81dfe3e8fac5588e12d2b880166d1743dbecd
+Directory: 0.10
+
+Tags: 0.11, 0.11.0
+GitCommit: 00e197d889426695446baec4e034b5ddbb15bcb3
+Directory: 0.11
+
+Tags: 0.12, 0.12.0, latest
+GitCommit: d7e73876549d205898b1922bcbf69e74ef11c288
+Directory: 0.12

+ 28 - 9
naughty-commits.sh

@@ -21,24 +21,39 @@ fi
 
 imgs="$(bashbrew list --repos "$@" | sort -u)"
 for img in $imgs; do
-	IFS=$'\n'
-	commits=( $(
+	commits="$(
 		bashbrew cat --format '
 			{{- range $e := .Entries -}}
 				{{- range $a := .Architectures -}}
 					{{- /* force `git fetch` */ -}}
 					{{- $froms := $.ArchDockerFroms $a $e -}}
-
-					{{- $e.ArchGitCommit $a -}}
+					{
+						{{- json "GitRepo" }}:{{ json ($e.ArchGitRepo $a) -}},
+						{{- json "GitFetch" }}:{{ json ($e.ArchGitFetch $a) -}},
+						{{- json "GitCommit" }}:{{ json ($e.ArchGitCommit $a) -}}
+					}
 					{{- "\n" -}}
 				{{- end -}}
 			{{- end -}}
-		' "$img" | sort -u
-	) )
-	unset IFS
+		' "$img" | jq -s 'unique'
+	)"
 
 	declare -A naughtyCommits=() naughtyTopCommits=() seenCommits=()
-	for topCommit in "${commits[@]}"; do
+	length="$(jq -r 'length' <<<"$commits")"
+	for (( i = 0; i < length; i++ )); do
+		topCommit="$(jq -r ".[$i].GitCommit" <<<"$commits")"
+		gitRepo="$(jq -r ".[$i].GitRepo" <<<"$commits")"
+		gitFetch="$(jq -r ".[$i].GitFetch" <<<"$commits")"
+
+		if ! _git fetch --quiet "$gitRepo" "$gitFetch:" ; then
+			naughtyCommits[$topCommit]="unable to to fetch specified GitFetch: $gitFetch"
+			naughtyTopCommits[$topCommit]="$topCommit"
+		elif ! _git merge-base --is-ancestor "$topCommit" 'FETCH_HEAD'; then
+			# check that the commit is in the GitFetch branch specified
+			naughtyCommits[$topCommit]="is not in the specified ref GitFetch: $gitFetch"
+			naughtyTopCommits[$topCommit]="$topCommit"
+		fi
+
 		IFS=$'\n'
 		potentiallyNaughtyGlobs=( '**.tar**' )
 		potentiallyNaughtyCommits=( $(_git log --diff-filter=DMT --format='format:%H' "$topCommit" -- "${potentiallyNaughtyGlobs[@]}") )
@@ -73,8 +88,12 @@ for img in $imgs; do
 			done
 
 			if [ "${#naughtyReasons[@]}" -gt 0 ]; then
+				: "${naughtyCommits[$commit]:=}"
+				if [ -n "${naughtyCommits[$commit]}" ]; then
+					naughtyCommits[$commit]+=$'\n'
+				fi
 				IFS=$'\n'
-				naughtyCommits[$commit]="${naughtyReasons[*]}"
+				naughtyCommits[$commit]+="${naughtyReasons[*]}"
 				unset IFS
 				naughtyTopCommits[$commit]="$topCommit"
 			fi