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,99 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Create a Gitea repository (idempotent).
|
||||
|
||||
.DESCRIPTION
|
||||
Mirrors deploy_skill/scripts/New-GitHubRepo.ps1. If the repo already exists,
|
||||
prints its URL and returns the existing object instead of failing.
|
||||
|
||||
.PARAMETER Name
|
||||
Repository name (required).
|
||||
|
||||
.PARAMETER Description
|
||||
Short description.
|
||||
|
||||
.PARAMETER Private
|
||||
Switch. If set, creates a private repo. Default public.
|
||||
|
||||
.PARAMETER Owner
|
||||
Optional. User (default) or org to create under.
|
||||
|
||||
.PARAMETER NoAutoInit
|
||||
Skip the Gitea-side README init (use when you will push an existing local
|
||||
repo with its own history).
|
||||
|
||||
.EXAMPLE
|
||||
.\New-GiteaRepo.ps1 -Name my-app -Description "demo" -Private
|
||||
.\New-GiteaRepo.ps1 -Name my-app -NoAutoInit
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidatePattern('^[A-Za-z0-9._-]+$')]
|
||||
[string]$Name,
|
||||
|
||||
[string]$Description = "",
|
||||
|
||||
[switch]$Private,
|
||||
|
||||
[string]$Owner,
|
||||
|
||||
[switch]$NoAutoInit
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$api = Join-Path $here "Invoke-GiteaApi.ps1"
|
||||
|
||||
$me = & $api -Path "/user"
|
||||
$effectiveOwner = if ($Owner) { $Owner } else { $me.login }
|
||||
Write-Host "Authenticated Gitea user: $($me.login)" -ForegroundColor Cyan
|
||||
|
||||
$existing = $null
|
||||
try {
|
||||
$existing = & $api -Path "/repos/$effectiveOwner/$Name"
|
||||
} catch {
|
||||
if ($_.Exception.Message -notmatch "404") { throw }
|
||||
$existing = $null
|
||||
}
|
||||
if ($existing) {
|
||||
Write-Host "Repository already exists: $($existing.html_url)" -ForegroundColor Yellow
|
||||
[PSCustomObject]@{
|
||||
full_name = $existing.full_name
|
||||
html_url = $existing.html_url
|
||||
clone_url = $existing.clone_url
|
||||
ssh_url = $existing.ssh_url
|
||||
private = $existing.private
|
||||
default_branch = $existing.default_branch
|
||||
} | Format-List
|
||||
return $existing
|
||||
}
|
||||
|
||||
$body = [ordered]@{
|
||||
name = $Name
|
||||
description = $Description
|
||||
private = [bool]$Private
|
||||
auto_init = (-not $NoAutoInit)
|
||||
has_issues = $true
|
||||
has_wiki = $false
|
||||
default_branch = "main"
|
||||
} | ConvertTo-Json -Compress
|
||||
|
||||
$endpoint = if ($Owner -and $Owner -ne $me.login) {
|
||||
"/orgs/$Owner/repos"
|
||||
} else {
|
||||
"/user/repos"
|
||||
}
|
||||
|
||||
Write-Host "Creating repository at: $endpoint" -ForegroundColor Cyan
|
||||
$created = & $api -Method POST -Path $endpoint -BodyJson $body
|
||||
|
||||
[PSCustomObject]@{
|
||||
full_name = $created.full_name
|
||||
html_url = $created.html_url
|
||||
clone_url = $created.clone_url
|
||||
ssh_url = $created.ssh_url
|
||||
private = $created.private
|
||||
default_branch = $created.default_branch
|
||||
} | Format-List
|
||||
|
||||
$created
|
||||
Reference in New Issue
Block a user