feat(git-control): add Git repository and branch access control features
- Introduced new scripts for managing Gitea repository permissions, including branch protection, user access, and organization-wide settings. - Added documentation for the git-control skill, detailing API usage and capabilities. - Included .gitignore to prevent committing sensitive configuration files. - Created references for Gitea API endpoints related to branch protection and user permissions.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Apply branch protection to all repos in an organization
|
||||
|
||||
param(
|
||||
[string]$ApiToken = $env:GITEA_TOKEN,
|
||||
[string]$GiteaBaseUrl = "http://afe.git:3000",
|
||||
[string]$Org,
|
||||
[string]$BranchName,
|
||||
[ValidateSet("lock", "unlock")]
|
||||
[string]$Action = "lock"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ConfigPath = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path) "..\config.local.json"
|
||||
if (-not $ApiToken -and (Test-Path $ConfigPath)) {
|
||||
$cfg = Get-Content $ConfigPath -Raw | ConvertFrom-Json
|
||||
$ApiToken = $cfg.ApiToken
|
||||
if ($cfg.GiteaBaseUrl) { $GiteaBaseUrl = $cfg.GiteaBaseUrl }
|
||||
}
|
||||
if (-not $ApiToken) { Write-Host "Error: ApiToken required"; exit 1 }
|
||||
if (-not $Org -or -not $BranchName) { Write-Host "Error: Org, BranchName required"; exit 1 }
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$BranchScript = Join-Path $ScriptDir "branch_protect.ps1"
|
||||
|
||||
$repos = @(& "$ScriptDir\list_orgs_repos.ps1" -ApiToken $ApiToken -GiteaBaseUrl $GiteaBaseUrl -Action list-repos -Org $Org)
|
||||
if (-not $repos -or $repos.Count -eq 0) { Write-Host "No repos found in org $Org"; exit 0 }
|
||||
|
||||
$count = 0
|
||||
foreach ($r in $repos) {
|
||||
if (-not $r) { continue }
|
||||
Write-Host "Processing $Org/$r..."
|
||||
& $BranchScript -ApiToken $ApiToken -GiteaBaseUrl $GiteaBaseUrl -Owner $Org -Repo $r -BranchName $BranchName -Action $Action
|
||||
$count++
|
||||
}
|
||||
Write-Host "Done. Processed $count repos."
|
||||
Reference in New Issue
Block a user