Compare commits

...

4 Commits

Author SHA1 Message Date
h z
d8dee3b062 Merge pull request 'feature/add-create-repo-script' (#2) from feature/add-create-repo-script into main
Reviewed-on: #2
2026-04-01 00:45:19 +00:00
lyn
32332bea41 fix(create-repo): update error message 2026-04-01 00:43:33 +00:00
lyn
38f5a52a14 fix(create-repo): require AGENT_WORKSPACE env var instead of default 2026-04-01 00:42:27 +00:00
lyn
ca9d3b4fe5 feat(git-hangman-lab): add create-repo command
- Add create-repo script for creating new repositories on git.hangman-lab.top
- Integrate create-repo into git-ctrl dispatcher
- Update SKILL.md with new command documentation
2026-04-01 00:38:47 +00:00
3 changed files with 81 additions and 6 deletions

View File

@@ -33,6 +33,16 @@ Generate an access token for the current user.
{baseDir}/scripts/git-ctrl generate-access-token
```
### Create Repository
Create a new git repository on git.hangman-lab.top.
```bash
{baseDir}/scripts/git-ctrl create-repo <repo-name>
```
> **Note**: The repository will be created at `${AGENT_WORKSPACE}/${repo-name}` (default: `/root/.openclaw/workspace/workspace-mentor`)
### Link Keycloak Account
Link Keycloak account with Gitea (for OAuth binding).

View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -euo pipefail
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [[ -z "${AGENT_WORKSPACE:-}" ]]; then
echo "Error: script must be executed by pcexec"
exit 1
fi
usage() {
echo "Usage: $0 <repo-name>"
echo ""
echo "Create a new git repository on git.hangman-lab.top"
echo ""
echo "Arguments:"
echo " repo-name Name of the repository to create"
exit 2
}
if [[ $# -eq 0 ]]; then
usage
fi
REPO_NAME="$1"
# Validate repo name (alphanumeric, hyphens, underscores only)
if ! [[ "$REPO_NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then
echo "Error: Invalid repository name '$REPO_NAME'"
echo "Only alphanumeric characters, hyphens, and underscores are allowed."
exit 1
fi
REPO_DIR="${AGENT_WORKSPACE}/${REPO_NAME}"
# Step 1: Create directory
echo "Creating directory: ${REPO_DIR}"
mkdir -p "${REPO_DIR}"
# Step 2: cd to directory
cd "${REPO_DIR}"
# Step 3: git init
echo "Initializing git repository..."
git init
# Step 4: git remote add origin
echo "Adding remote origin..."
USERNAME="$(secret-mgr get-username --key git)"
REMOTE_URL="https://git.hangman-lab.top/${USERNAME}/${REPO_NAME}.git"
git remote add origin "${REMOTE_URL}"
echo " Remote: ${REMOTE_URL}"
# Step 5: Run repo-config
echo "Configuring repository..."
"$SCRIPT_DIR/repo-config" --repo-path "${REPO_DIR}"
echo ""
echo "Done! Repository created at: ${REPO_DIR}"
echo "Remote: ${REMOTE_URL}"

View File

@@ -10,12 +10,13 @@ if [[ $# -eq 0 ]]; then
echo "Commands:"
echo " check-git-cred Verify git credentials"
echo " create-git-account Create a new git account"
echo " generate-access-token Generate access token for current user"
echo " link-keycloak Link Keycloak account with Gitea"
echo " repo-add-collaborators Add collaborator to repository"
echo " repo-config Configure repository"
echo " external-login-ctrl Enable/disable local login"
echo " reset-password Reset user password"
echo " create-repo Create a new repository"
echo " generate-access-token Generate access token for current user"
echo " link-keycloak Link Keycloak account with Gitea"
echo " repo-add-collaborators Add collaborator to repository"
echo " repo-config Configure repository"
echo " external-login-ctrl Enable/disable local login"
echo " reset-password Reset user password"
exit 1
fi
@@ -31,6 +32,9 @@ case "$subcommand" in
create-git-account)
"$SCRIPT_DIR/create-git-account" "$@"
;;
create-repo)
"$SCRIPT_DIR/create-repo" "$@"
;;
generate-access-token)
"$SCRIPT_DIR/generate-access-token" "$@"
;;