Skip to content

Commit f52da7f

Browse files
committed
fix search query
Add default branch to repo list Adjust table object for community repo to include default branch
1 parent 2d81e06 commit f52da7f

4 files changed

Lines changed: 50 additions & 33 deletions

File tree

CommunityRepos.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"Owner": "CyberDrain",
99
"Visibility": "public",
1010
"WriteAccess": false,
11+
"DefaultBranch": "main",
1112
"RepoPermissions": {
1213
"admin": false,
1314
"maintain": false,
@@ -25,6 +26,7 @@
2526
"Owner": "j0eyv",
2627
"Visibility": "public",
2728
"WriteAccess": false,
29+
"DefaultBranch": "main",
2830
"RepoPermissions": {
2931
"admin": false,
3032
"maintain": false,
@@ -42,6 +44,7 @@
4244
"Owner": "SkipToTheEndpoint",
4345
"Visibility": "public",
4446
"WriteAccess": false,
47+
"DefaultBranch": "main",
4548
"RepoPermissions": {
4649
"admin": false,
4750
"maintain": false,

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ExecCommunityRepo.ps1

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ function Invoke-ExecCommunityRepo {
2323
'Add' {
2424
$Repo = Invoke-GitHubApiRequest -Path "repositories/$($Id)"
2525
$RepoEntity = @{
26-
PartitionKey = 'CommunityRepos'
27-
RowKey = [string]$Repo.id
28-
Name = [string]$Repo.name
29-
Description = [string]$Repo.description
30-
URL = [string]$Repo.html_url
31-
FullName = [string]$Repo.full_name
32-
Owner = [string]$Repo.owner.login
33-
Visibility = [string]$Repo.visibility
34-
WriteAccess = [bool]$Repo.permissions.push
35-
Permissions = [string]($Repo.permissions | ConvertTo-Json -Compress)
26+
PartitionKey = 'CommunityRepos'
27+
RowKey = [string]$Repo.id
28+
Name = [string]$Repo.name
29+
Description = [string]$Repo.description
30+
URL = [string]$Repo.html_url
31+
FullName = [string]$Repo.full_name
32+
Owner = [string]$Repo.owner.login
33+
Visibility = [string]$Repo.visibility
34+
WriteAccess = [bool]$Repo.permissions.push
35+
DefaultBranch = [string]$Repo.default_branch
36+
Permissions = [string]($Repo.permissions | ConvertTo-Json -Compress)
3637
}
3738

3839
Add-CIPPAzDataTableEntity @Table -Entity $RepoEntity -Force | Out-Null
@@ -46,17 +47,18 @@ function Invoke-ExecCommunityRepo {
4647
if ($RepoEntity) {
4748
$Repo = Invoke-GitHubApiRequest -Path "repositories/$($Id)"
4849
$Update = @{
49-
PartitionKey = 'CommunityRepos'
50-
RowKey = [string]$Repo.id
51-
Name = [string]$Repo.name
52-
Description = [string]$Repo.description
53-
URL = [string]$Repo.html_url
54-
FullName = [string]$Repo.full_name
55-
Owner = [string]$Repo.owner.login
56-
Visibility = [string]$Repo.visibility
57-
WriteAccess = [bool]$Repo.permissions.push
58-
Permissions = [string]($Repo.permissions | ConvertTo-Json -Compress)
59-
ETag = $RepoEntity.ETag
50+
PartitionKey = 'CommunityRepos'
51+
RowKey = [string]$Repo.id
52+
Name = [string]$Repo.name
53+
Description = [string]$Repo.description
54+
URL = [string]$Repo.html_url
55+
FullName = [string]$Repo.full_name
56+
Owner = [string]$Repo.owner.login
57+
Visibility = [string]$Repo.visibility
58+
WriteAccess = [bool]$Repo.permissions.push
59+
DefaultBranch = [string]$Repo.default_branch
60+
Permissions = [string]($Repo.permissions | ConvertTo-Json -Compress)
61+
ETag = $RepoEntity.ETag
6062
}
6163

6264
Update-CIPPAzDataTableEntity @Table -Entity $Update

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ExecGitHubAction.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@ function Invoke-ExecGitHubAction {
1313
param($Request, $TriggerMetadata)
1414

1515
$Action = $Request.Query.Action ?? $Request.Body.Action
16-
$SplatParams = ($Request.Query ?? $Request.Body) | Select-Object -ExcludeProperty Action, TenantFilter | ConvertTo-Json | ConvertFrom-Json -AsHashtable
16+
17+
if ($Request.Query.Action) {
18+
$Parameters = $Request.Query
19+
} else {
20+
$Parameters = $Request.Body
21+
}
22+
23+
$SplatParams = $Parameters | Select-Object -ExcludeProperty Action, TenantFilter | ConvertTo-Json | ConvertFrom-Json -AsHashtable
24+
25+
Write-Information ($SplatParams | ConvertTo-Json)
1726

1827
switch ($Action) {
1928
'Search' {
20-
$Results = (Search-GitHub @SplatParams).items
29+
$SearchResults = Search-GitHub @SplatParams
30+
$Results = @($SearchResults.items)
2131
$Metadata = $SearchResults | Select-Object -Property total_count, incomplete_results
2232
}
2333
'GetFileContents' {

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ListCommunityRepos.ps1

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ function Invoke-ListCommunityRepos {
2323
foreach ($Repo in $DefaultCommunityRepos) {
2424
if ($Repos.Url -notcontains $Repo.Url) {
2525
$Entity = [PSCustomObject]@{
26-
PartitionKey = 'CommunityRepos'
27-
RowKey = $Repo.Id
28-
Name = $Repo.Name
29-
Description = $Repo.Description
30-
URL = $Repo.URL
31-
FullName = $Repo.FullName
32-
Owner = $Repo.Owner
33-
Visibility = $Repo.Visibility
34-
WriteAccess = $Repo.WriteAccess
35-
Permissions = [string]($Repo.RepoPermissions | ConvertTo-Json)
26+
PartitionKey = 'CommunityRepos'
27+
RowKey = $Repo.Id
28+
Name = $Repo.Name
29+
Description = $Repo.Description
30+
URL = $Repo.URL
31+
FullName = $Repo.FullName
32+
Owner = $Repo.Owner
33+
Visibility = $Repo.Visibility
34+
WriteAccess = $Repo.WriteAccess
35+
DefaultBranch = $Repo.DefaultBranch
36+
Permissions = [string]($Repo.RepoPermissions | ConvertTo-Json)
3637
}
3738
Add-CIPPAzDataTableEntity @Table -Entity $Entity
3839
$DefaultsMissing = $true
@@ -52,6 +53,7 @@ function Invoke-ListCommunityRepos {
5253
Owner = $_.Owner
5354
Visibility = $_.Visibility
5455
WriteAccess = $_.WriteAccess
56+
DefaultBranch = $_.DefaultBranch
5557
RepoPermissions = $_.Permissions | ConvertFrom-Json
5658
}
5759
}

0 commit comments

Comments
 (0)