From 12e644a6d913a39e2eba74e7043c58688e0a1b84 Mon Sep 17 00:00:00 2001 From: cadsit Date: Wed, 20 May 2020 13:05:56 -0400 Subject: [PATCH 1/3] page through github statuses for manifest URL --- tools/devops/utils.csx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/devops/utils.csx b/tools/devops/utils.csx index b34747b27b..15e6f1eb51 100644 --- a/tools/devops/utils.csx +++ b/tools/devops/utils.csx @@ -34,14 +34,25 @@ string DownloadWithGithubAuth (string uri) string manifest_url = null; string GetManifestUrl (string hash) { - if (manifest_url == null) { - var url = $"https://api.github.com/repos/xamarin/xamarin-macios/statuses/{hash}"; - var json = JToken.Parse (DownloadWithGithubAuth (url)); - var value = (JValue) ((JArray) json).Where ((v) => v ["context"].ToString () == "manifest").Select ((v) => v ["target_url"]).FirstOrDefault (); - manifest_url = (string) value?.Value; - if (manifest_url == null) - throw new Exception ($"Could not find the manifest for {hash}. Is the commit already built by CI?"); + var page = 1; + var hasContent = true; + while (manifest_url == null && hasContent) + { + var url = $"https://api.github.com/repos/xamarin/xamarin-macios/statuses/{hash}?page={page}"; + var content = DownloadWithGithubAuth (url); + hasContent &= !String.IsNullOrEmpty(content); + if (hasContent) + { + var json = JToken.Parse (content); + var value = (JValue) ((JArray) json).Where ((v) => v ["context"].ToString () == "manifest").Select ((v) => v ["target_url"]).FirstOrDefault (); + manifest_url = (string) value?.Value; + } + page++; } + + if (manifest_url == null) + throw new Exception ($"Could not find the manifest for {hash}. Is the commit already built by CI?"); + return manifest_url; } From c3676e77b677e1b846482c5980e81998f366953a Mon Sep 17 00:00:00 2001 From: cadsit Date: Wed, 20 May 2020 13:36:19 -0400 Subject: [PATCH 2/3] Check to see if the content has values (rather than being the empty string) --- tools/devops/utils.csx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/devops/utils.csx b/tools/devops/utils.csx index 15e6f1eb51..1e5ad6c9b9 100644 --- a/tools/devops/utils.csx +++ b/tools/devops/utils.csx @@ -39,12 +39,12 @@ string GetManifestUrl (string hash) while (manifest_url == null && hasContent) { var url = $"https://api.github.com/repos/xamarin/xamarin-macios/statuses/{hash}?page={page}"; - var content = DownloadWithGithubAuth (url); - hasContent &= !String.IsNullOrEmpty(content); + var json = JToken.Parse (DownloadWithGithubAuth (url)); + var statuses = (JValue) ((JArray) json); + hasContent &= statuses.HasValues; if (hasContent) { - var json = JToken.Parse (content); - var value = (JValue) ((JArray) json).Where ((v) => v ["context"].ToString () == "manifest").Select ((v) => v ["target_url"]).FirstOrDefault (); + var value = statuses.Where ((v) => v ["context"].ToString () == "manifest").Select ((v) => v ["target_url"]).FirstOrDefault (); manifest_url = (string) value?.Value; } page++; From 4bd68fd65387cf000a1df722d3bf07587a5402fd Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 20 May 2020 19:59:04 +0200 Subject: [PATCH 3/3] Fix code style. --- tools/devops/utils.csx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/devops/utils.csx b/tools/devops/utils.csx index 1e5ad6c9b9..03e0a2dd43 100644 --- a/tools/devops/utils.csx +++ b/tools/devops/utils.csx @@ -36,14 +36,12 @@ string GetManifestUrl (string hash) { var page = 1; var hasContent = true; - while (manifest_url == null && hasContent) - { + while (manifest_url == null && hasContent) { var url = $"https://api.github.com/repos/xamarin/xamarin-macios/statuses/{hash}?page={page}"; var json = JToken.Parse (DownloadWithGithubAuth (url)); var statuses = (JValue) ((JArray) json); hasContent &= statuses.HasValues; - if (hasContent) - { + if (hasContent) { var value = statuses.Where ((v) => v ["context"].ToString () == "manifest").Select ((v) => v ["target_url"]).FirstOrDefault (); manifest_url = (string) value?.Value; }