public override string GetPayload() { List <CodeOwnerEntry> entries = CodeOwnersFile.ParseFile(_codeownersFile); foreach (CodeOwnerEntry entry in entries) { // If we have labels for the specific codeowners entry, add that to the triage list if (entry.ServiceLabels.Any()) { // Remove the '@' from the owners handle IEnumerable <string> mentionees = entry.Owners.Select(x => x.Replace("@", "").Trim()); //add the service AddService(entry.ServiceLabels, mentionees); } } Colorizer.WriteLine("Found [Yellow!{0}] service routes.", RouteCount); foreach (TriageConfig triage in _triageConfig) { Colorizer.WriteLine("Labels:[Yellow!{0}], Owners:[Yellow!{1}]", string.Join(',', triage.Labels), string.Join(',', triage.Mentionee)); } return(s_template .Replace("###repo###", GetTaskId()) .Replace("###labelsAndMentions###", string.Join(",", _triageConfig))); }
internal override void ReadConfigurationFromFile(string configurationFile) { List <CodeOwnerEntry> entries = CodeOwnersFile.ParseFile(configurationFile); foreach (CodeOwnerEntry entry in entries) { // If we have labels for the specific codeowners entry, add that to the triage list if (entry.ServiceLabels.Any()) { // Remove the '@' from the owners handle IEnumerable <string> mentionees = entry.Owners.Select(x => x.Replace("@", "").Trim()); //add the service AddRoute(entry.ServiceLabels, mentionees); } } }
internal override void ReadConfigurationFromFile(string configurationFile) { List <CodeOwnerEntry> entries = CodeOwnersFile.ParseFile(configurationFile); // Filter our the list of entries that we want to create. for (int i = 0; i < entries.Count; i++) { // Entries with wildcards are not yet supported if (entries[i].ContainsWildcard) { // log a warning there if (entries[i].PRLabels.Any()) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' contains a wildcard and a label '[Magenta!{1}]' which is not supported!", entries[i].PathExpression, string.Join(',', entries[i].PRLabels)); } continue; //TODO: regex expressions are not yet supported } if (entries[i].PathExpression.IndexOf(CodeOwnerEntry.MissingFolder, StringComparison.OrdinalIgnoreCase) != -1) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' is marked with the non-existing path marker.", entries[i].PathExpression); continue; } // Entries with more than one label are not yet supported. if (entries[i].PRLabels.Count > 1) { Colorizer.WriteLine("[Yellow!Warning]: Multiple labels for the same path '[Cyan!{0}]' are not yet supported", entries[i].PathExpression); continue; } if (entries[i].PRLabels.Count == 0) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' does not contain a label.", entries[i].PathExpression, string.Join(',', entries[i].PRLabels)); continue; } AddEntry(entries[i].PathExpression, entries[i].PRLabels.First()); } }
public override string GetPayload() { List <CodeOwnerEntry> entries = CodeOwnersFile.ParseFile(_codeownersFile); StringBuilder configPayload = new StringBuilder(); List <CodeOwnerEntry> entriesToCreate = new List <CodeOwnerEntry>(); // Filter our the list of entries that we want to create. for (int i = 0; i < entries.Count; i++) { // Entries with wildcards are not yet supported if (entries[i].ContainsWildcard) { // log a warning there if (entries[i].PRLabels.Any()) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' contains a wildcard and a label '[Magenta!{1}]' which is not supported!", entries[i].PathExpression, string.Join(',', entries[i].PRLabels)); } continue; //TODO: regex expressions are not yet supported } if (entries[i].PathExpression.IndexOf(CodeOwnerEntry.MissingFolder, StringComparison.OrdinalIgnoreCase) != -1) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' is marked with the non-existing path marker.", entries[i].PathExpression); continue; } // Entries with more than one label are not yet supported. if (entries[i].PRLabels.Count > 1) { Colorizer.WriteLine("[Yellow!Warning]: Multiple labels for the same path '[Cyan!{0}]' are not yet supported", entries[i].PathExpression); continue; } if (entries[i].PRLabels.Count == 0) { Colorizer.WriteLine("[Yellow!Warning]: The path '[Cyan!{0}]' does not contain a label.", entries[i].PathExpression, string.Join(',', entries[i].PRLabels)); continue; } entriesToCreate.Add(entries[i]); } Colorizer.WriteLine("Found the following rules:"); // Create the payload. foreach (var entry in entriesToCreate) { // get the payload string entryPayload = ToConfigString(entry); Colorizer.WriteLine("[Cyan!{0}] => [Magenta!{1}]", entry.PathExpression, entry.PRLabels.FirstOrDefault()); configPayload.Append(ToConfigString(entry)); configPayload.Append(','); } // remove the trailing ',' configPayload.Remove(configPayload.Length - 1, 1); // Log the set of paths we are creating. // create the payload from the template return(s_template .Replace("###taskId###", GetTaskId()) .Replace("###labelConfig###", configPayload.ToString())); }