Skip to content

Commit

Permalink
Merge GetDefaultDisplaySuffix method with Sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Jan 12, 2025
1 parent 8285f41 commit 2f379f7
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/Runner.Server/Controllers/MessageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,20 +1856,6 @@ private HookResponse ConvertYaml2(string fileRelativePath, string content, strin
}
{
int i = 0;
Func<IEnumerable<string>, string> defaultDisplaySuffix = item => {
var displaySuffix = new StringBuilder();
int z = 0;
foreach (var mk in item) {
if(!string.IsNullOrEmpty(mk)) {
displaySuffix.Append(z++ == 0 ? "(" : ", ");
displaySuffix.Append(mk);
}
}
if(z > 0) {
displaySuffix.Append( ")");
}
return displaySuffix.ToString();
};
var usesJob = (from r in run where r.Key.AssertString($"jobs.{jobname} mapping key").Value == "uses" select r).FirstOrDefault().Value != null;
if(usesJob) {
if((callingJob?.Depth ?? 0) >= MaxWorkflowDepth && MaxWorkflowDepth >= 0) {
Expand Down Expand Up @@ -2067,7 +2053,7 @@ private HookResponse ConvertYaml2(string fileRelativePath, string content, strin
cancelAll(cancelreqmsg);
return;
}
var j = act(defaultDisplaySuffix(from displayitem in keys.SelectMany(key => item[key].Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
var j = act(StrategyUtils.GetDefaultDisplaySuffix(from displayitem in keys.SelectMany(key => item[key].Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
if(j != null) {
jobs.Enqueue(j);
}
Expand All @@ -2078,7 +2064,7 @@ private HookResponse ConvertYaml2(string fileRelativePath, string content, strin
cancelAll(cancelreqmsg);
return;
}
var j = act(defaultDisplaySuffix(from displayitem in item.SelectMany(it => it.Value.Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
var j = act(StrategyUtils.GetDefaultDisplaySuffix(from displayitem in item.SelectMany(it => it.Value.Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
if(j != null) {
jobs.Enqueue(j);
}
Expand Down Expand Up @@ -3550,20 +3536,6 @@ private HookResponse AzureDevopsMain(string fileRelativePath, string content, st
}
{
int i = 0;
Func<IEnumerable<string>, string> defaultDisplaySuffix = item => {
var displaySuffix = new StringBuilder();
int z = 0;
foreach (var mk in item) {
if(!string.IsNullOrEmpty(mk)) {
displaySuffix.Append(z++ == 0 ? "(" : ", ");
displaySuffix.Append(mk);
}
}
if(z > 0) {
displaySuffix.Append( ")");
}
return displaySuffix.ToString();
};
Func<string, Dictionary<string, TemplateToken>, Func<TaskResult?, Job>> act = (displaySuffix, item) => {
var providedVars = new Dictionary<string, VariableValue>(StringComparer.OrdinalIgnoreCase);
int c = i++;
Expand Down Expand Up @@ -3795,7 +3767,7 @@ private HookResponse AzureDevopsMain(string fileRelativePath, string content, st
cancelAll(cancelreqmsg);
return;
}
var j = act(defaultDisplaySuffix(from displayitem in keys.SelectMany(key => item[key].Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
var j = act(StrategyUtils.GetDefaultDisplaySuffix(from displayitem in keys.SelectMany(key => item[key].Traverse(true)) where !(displayitem is SequenceToken || displayitem is MappingToken) select displayitem.ToString()), item);
if(j != null) {
jobs.Enqueue(j);
}
Expand Down

0 comments on commit 2f379f7

Please sign in to comment.