Agrega gitea_skill: skill para operar Gitea self-hosted (scripts API BOM-safe + push headless sin persistir token, SKILL/TOOLS/api-index). Actualiza CLAUDE.md, README.md, .env.example.
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Get or search a Gitea repository.
|
||||
|
||||
.DESCRIPTION
|
||||
Three modes:
|
||||
-Name <repo> -> GET /repos/{owner}/{name} (default owner = auth user)
|
||||
-Search <term> -> GET /repos/search?q=<term>
|
||||
-List -> GET /repos/search (all visible to the token)
|
||||
|
||||
.PARAMETER Owner
|
||||
Owner (user or org). Defaults to the authenticated user.
|
||||
|
||||
.PARAMETER Name
|
||||
Exact repository name to look up.
|
||||
|
||||
.PARAMETER Search
|
||||
Free-text search term.
|
||||
|
||||
.PARAMETER List
|
||||
Switch: list all visible repos.
|
||||
|
||||
.EXAMPLE
|
||||
.\Get-GiteaRepo.ps1 -Name Proxmox-Coolify-Manager
|
||||
.\Get-GiteaRepo.ps1 -Search manager
|
||||
.\Get-GiteaRepo.ps1 -List
|
||||
#>
|
||||
param(
|
||||
[string]$Owner,
|
||||
[Parameter(ParameterSetName = "ByName")]
|
||||
[string]$Name,
|
||||
[Parameter(ParameterSetName = "BySearch")]
|
||||
[string]$Search,
|
||||
[Parameter(ParameterSetName = "ListAll")]
|
||||
[switch]$List
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$api = Join-Path $here "Invoke-GiteaApi.ps1"
|
||||
|
||||
function Resolve-GiteaOwner {
|
||||
param([string]$OwnerArg)
|
||||
if ($OwnerArg) { return $OwnerArg }
|
||||
$me = & $api -Path "/user"
|
||||
return $me.login
|
||||
}
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByName" {
|
||||
if (-not $Name) { throw "Provide -Name." }
|
||||
$o = Resolve-GiteaOwner -OwnerArg $Owner
|
||||
try {
|
||||
$r = & $api -Path "/repos/$o/$Name"
|
||||
[PSCustomObject]@{
|
||||
full_name = $r.full_name
|
||||
private = $r.private
|
||||
default_branch = $r.default_branch
|
||||
clone_url = $r.clone_url
|
||||
html_url = $r.html_url
|
||||
ssh_url = $r.ssh_url
|
||||
updated_at = $r.updated_at
|
||||
} | Format-List
|
||||
} catch {
|
||||
if ($_.Exception.Message -match "404") {
|
||||
Write-Host "Repository not found: $o/$Name" -ForegroundColor Yellow
|
||||
return
|
||||
}
|
||||
throw
|
||||
}
|
||||
}
|
||||
"BySearch" {
|
||||
$term = [uri]::EscapeDataString($Search)
|
||||
$r = & $api -Path "/repos/search?q=$term&limit=50"
|
||||
$r.data | Select-Object full_name, private, default_branch, updated_at | Format-Table -AutoSize
|
||||
}
|
||||
"ListAll" {
|
||||
$r = & $api -Path "/repos/search?limit=50"
|
||||
$r.data | Select-Object full_name, private, default_branch, updated_at | Format-Table -AutoSize
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user