1.9 KiB
1.9 KiB
description
| description |
|---|
| Switch default Gitea organization |
Switch the default Gitea organization in configuration.
工作目录
macOS / Linux:
~/.config/gitea/
Windows:
%USERPROFILE%\.config\gitea\
User input format: $ARGUMENTS = organization name
Example usage:
/gitea-switch-org ai
/gitea-switch-org my-team
Please perform the following:
-
Check configuration exists:
- Config file:
- macOS/Linux:
~/.config/gitea/config.env - Windows:
%USERPROFILE%\.config\gitea\config.env
- macOS/Linux:
- If not exists: prompt user to run
/gitea-reset
- Config file:
-
Load configuration:
macOS / Linux:
source ~/.config/gitea/config.env
Windows PowerShell:
Get-Content "$env:USERPROFILE\.config\gitea\config.env" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2], 'Process')
}
}
-
Parse user input:
- Organization name from
$ARGUMENTS - If empty: show usage and examples
- Organization name from
-
Validate organization exists:
- API:
GET ${GITEA_URL}/api/v1/orgs/${org_name} - Header:
Authorization: token ${GITEA_TOKEN} - If 404: Show error and list available organizations:
curl -s -H "Authorization: token $GITEA_TOKEN" \ "${GITEA_URL}/api/v1/user/orgs" | jq -r '.[].username'
- API:
-
Update configuration file:
- If
GITEA_DEFAULT_ORGexists: update the line - If not exists: add after
GITEA_TOKEN - Handle macOS (sed -i '') and Linux (sed -i) differences
- If
-
Display result in Chinese:
✓ 默认组织已切换到: [org_name]
现在可以:
- 创建仓库: /create-gitea-repo my-project
(将创建到 [org_name]/my-project)
- 查看配置: /gitea-config
Notes:
- Switching organization doesn't affect existing repositories or runners
- Only affects default owner for future repository creation
- Can switch anytime