Skip to content

Commit

Permalink
for Search() based operations ADO can't handle eq true
Browse files Browse the repository at this point in the history
  • Loading branch information
anamnavi committed Dec 6, 2024
1 parent 5f6cc49 commit 2d7f3ef
Showing 1 changed file with 68 additions and 18 deletions.
86 changes: 68 additions & 18 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -917,16 +917,26 @@ private string FindAllFromTypeEndPoint(bool includePrerelease, bool isSearchingM
}

// JFrog/Artifactory requires an empty search term to enumerate all packages in the feed
// It also deems 'IsLatestVersion eq true' and 'IsAbsoluteLatestVersion eq true' in the filter to be a bad request, so we use 'IsLatestVersion' or 'IsAbsoluteLatestVersion' only
if (_isJFrogRepo) {
queryBuilder.SearchTerm = "''";
}

if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
} else {
filterBuilder.AddCriterion("IsLatestVersion eq true");
if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
} else {
filterBuilder.AddCriterion("IsLatestVersion eq true");
}
}
else {
if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion");
} else {
filterBuilder.AddCriterion("IsLatestVersion");
}
}

var requestUrlV2 = $"{Repository.Uri}{typeEndpoint}/Search()?{queryBuilder.BuildQueryString()}";
return HttpRequestCall(requestUrlV2, out errRecord);
}
Expand Down Expand Up @@ -956,17 +966,33 @@ private string FindTagFromEndpoint(string[] tags, bool includePrerelease, bool i
queryBuilder.AdditionalParameters["$orderby"] = "Id desc";
}

// JFrog/Artifactory requires an empty search term to enumerate all packages in the feed
if (_isJFrogRepo) {
queryBuilder.SearchTerm = "''";
}

if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
filterBuilder.AddCriterion("IsAbsoluteLatestVersion");
} else {
filterBuilder.AddCriterion("IsLatestVersion eq true");
}
filterBuilder.AddCriterion("IsLatestVersion");
}

// // JFrog/Artifactory requires an empty search term to enumerate all packages in the feed
// // It also deems 'IsLatestVersion eq true' and 'IsAbsoluteLatestVersion eq true' in the filter to be a bad request, so we use 'IsLatestVersion' or 'IsAbsoluteLatestVersion' only
// if (_isJFrogRepo) {
// queryBuilder.SearchTerm = "''";

// if (includePrerelease) {
// queryBuilder.AdditionalParameters["includePrerelease"] = "true";
// filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
// } else {
// filterBuilder.AddCriterion("IsLatestVersion eq true");
// }
// }
// else {
// if (includePrerelease) {
// queryBuilder.AdditionalParameters["includePrerelease"] = "true";
// filterBuilder.AddCriterion("IsAbsoluteLatestVersion");
// } else {
// filterBuilder.AddCriterion("IsLatestVersion");
// }
// }

filterBuilder.AddCriterion($"substringof('PS{(isSearchingModule ? "Module" : "Script")}', Tags) eq true");

Expand Down Expand Up @@ -1040,11 +1066,23 @@ private string FindNameGlobbing(string packageName, ResourceType type, bool incl
queryBuilder.AdditionalParameters["$orderby"] = "Id desc";
}

// JFrog/Artifactory requires an empty search term to enumerate all packages in the feed
// It also deems 'IsLatestVersion eq true' and 'IsAbsoluteLatestVersion eq true' in the filter to be a bad request, so we use 'IsLatestVersion' or 'IsAbsoluteLatestVersion' only
if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
if (_isJFrogRepo) {
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
}
else {
filterBuilder.AddCriterion("IsAbsoluteLatestVersion");
}
} else {
filterBuilder.AddCriterion("IsLatestVersion eq true");
if (_isJFrogRepo) {
filterBuilder.AddCriterion("IsLatestVersion eq true");
}
else {
filterBuilder.AddCriterion("IsLatestVersion");
}
}

var names = packageName.Split(new char[] {'*'}, StringSplitOptions.RemoveEmptyEntries);
Expand Down Expand Up @@ -1134,11 +1172,23 @@ private string FindNameGlobbingWithTag(string packageName, string[] tags, Resour
queryBuilder.AdditionalParameters["$orderby"] = "Id desc";
}

// JFrog/Artifactory requires an empty search term to enumerate all packages in the feed
// It also deems 'IsLatestVersion eq true' and 'IsAbsoluteLatestVersion eq true' in the filter to be a bad request, so we use 'IsLatestVersion' or 'IsAbsoluteLatestVersion' only
if (includePrerelease) {
queryBuilder.AdditionalParameters["includePrerelease"] = "true";
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
if (_isJFrogRepo) {
filterBuilder.AddCriterion("IsAbsoluteLatestVersion eq true");
}
else {
filterBuilder.AddCriterion("IsAbsoluteLatestVersion");
}
} else {
filterBuilder.AddCriterion("IsLatestVersion eq true");
if (_isJFrogRepo) {
filterBuilder.AddCriterion("IsLatestVersion eq true");
}
else {
filterBuilder.AddCriterion("IsLatestVersion");
}
}

var names = packageName.Split(new char[] {'*'}, StringSplitOptions.RemoveEmptyEntries);
Expand Down

0 comments on commit 2d7f3ef

Please sign in to comment.