Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for non-PSGallery repos adding script endpoint #1526

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal class V2ServerAPICalls : ServerApiCall
public FindResponseType v2FindResponseType = FindResponseType.ResponseString;
private bool _isADORepo;
private bool _isJFrogRepo;
private bool _isPSGalleryRepo;

#endregion

Expand All @@ -60,6 +61,7 @@ public V2ServerAPICalls (PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, N
var repoURL = repository.Uri.ToString().ToLower();
_isADORepo = repoURL.Contains("pkgs.dev.azure.com") || repoURL.Contains("pkgs.visualstudio.com");
_isJFrogRepo = repoURL.Contains("jfrog");
_isPSGalleryRepo = repoURL.Contains("powershellgallery.com/api/v2");
}

#endregion
Expand Down Expand Up @@ -806,7 +808,7 @@ private HttpContent HttpRequestCallForContent(string requestUrlV2, out ErrorReco
private string FindAllFromTypeEndPoint(bool includePrerelease, bool isSearchingModule, int skip, out ErrorRecord errRecord)
{
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::FindAllFromTypeEndPoint()");
string typeEndpoint = isSearchingModule ? String.Empty : "/items/psscript";
string typeEndpoint = _isPSGalleryRepo && !isSearchingModule ? "/items/psscript" : String.Empty;
string paginationParam = $"&$orderby=Id desc&$inlinecount=allpages&$skip={skip}&$top=6000";
var prereleaseFilter = includePrerelease ? "IsAbsoluteLatestVersion&includePrerelease=true" : "IsLatestVersion";

Expand All @@ -826,7 +828,7 @@ private string FindTagFromEndpoint(string[] tags, bool includePrerelease, bool i
// type: S -> just search Scripts end point
// type: DSCResource -> just search Modules
// type: Command -> just search Modules
string typeEndpoint = isSearchingModule ? String.Empty : "/items/psscript";
string typeEndpoint = _isPSGalleryRepo && !isSearchingModule ? "/items/psscript" : String.Empty;
string paginationParam = $"&$orderby=Id desc&$inlinecount=allpages&$skip={skip}&$top=6000";
var prereleaseFilter = includePrerelease ? "includePrerelease=true&$filter=IsAbsoluteLatestVersion" : "$filter=IsLatestVersion";
string typeFilterPart = isSearchingModule ? $" and substringof('PSModule', Tags) eq true" : $" and substringof('PSScript', Tags) eq true";
Expand Down
Loading