public QueuedItemInfo(int id, JobId jobId, PullRequestInfo prInfo, int?buildNumber) { Id = id; JobId = jobId; PullRequestInfo = prInfo; BuildNumber = buildNumber; }
internal static bool TryParsePullRequestInfo(JArray actions, out PullRequestInfo info) { var container = actions.FirstOrDefault(x => x["parameters"] != null); if (container == null) { info = null; return(false); } string sha1 = null; string pullLink = null; int? pullId = null; string pullAuthor = null; string pullAuthorEmail = null; string commitAuthorEmail = null; var parameters = (JArray)container["parameters"]; foreach (var pair in parameters) { switch (pair.Value <string>("name")) { case "ghprbActualCommit": sha1 = pair.Value <string>("value") ?? sha1; break; case "ghprbPullId": pullId = pair.Value <int>("value"); break; case "ghprbPullAuthorLogin": pullAuthor = pair.Value <string>("value") ?? pullAuthor; break; case "ghprbPullAuthorEmail": pullAuthorEmail = pair.Value <string>("value") ?? pullAuthorEmail; break; case "ghprbActualCommitAuthorEmail": commitAuthorEmail = pair.Value <string>("value") ?? commitAuthorEmail; break; case "ghprbPullLink": pullLink = pair.Value <string>("value") ?? pullLink; break; default: break; } } // It's possible for the pull email to be blank if the Github settings for the user // account hides their public email address. In that case fall back to the commit // author. It's generally the same value and serves as a nice backup identifier. if (string.IsNullOrEmpty(pullAuthorEmail)) { pullAuthorEmail = commitAuthorEmail; } if (sha1 == null || pullLink == null || pullId == null || pullAuthorEmail == null) { info = null; return(false); } info = new PullRequestInfo( author: pullAuthor, authorEmail: pullAuthorEmail, id: pullId.Value, pullUrl: pullLink, sha1: sha1); return(true); }