Skip to content

Commit

Permalink
Fix inconsistend ordering for build listing API
Browse files Browse the repository at this point in the history
  • Loading branch information
dasMulli committed Jan 29, 2021
1 parent cad2a03 commit c8f996f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,19 @@ export async function getLastSuccessfulBuildByStage(
}
}

builds.sort((a, b) => <any>b.queueTime - <any>a.queueTime);

let foundSelf = false;

for (let buildIndex = 0; buildIndex < builds.length; buildIndex++) {
const build = builds[buildIndex];
agentApi.logInfo (`Comparing ${build.id} against ${buildId}`);
// force the cast to string as was getting a type mimatch
if (build.id.toString() === buildId.toString()) {
agentApi.logInfo("Ignore compare against self");
foundSelf = true;
} else if (!foundSelf) {
agentApi.logInfo(`Ignoring ${build.id} (${build.buildNumber}) since not yet reached the current build`);
} else {
if (tags.length === 0 ||
(tags.length > 0 && build.tags.sort().join(",") === tags.sort().join(","))) {
Expand Down

0 comments on commit c8f996f

Please sign in to comment.