diff options
author | heqnx <root@heqnx.com> | 2025-05-16 02:33:53 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-05-16 02:33:53 +0300 |
commit | cc34ae34b753ebaa13519500fc029e4c43fa025f (patch) | |
tree | c612d313c82e82895254acca15ca8f8218d06293 /git-shell-commands/create-repo | |
parent | c963ccecb4e0414bc1e384655fa3b1b813902975 (diff) | |
download | cgit-main.tar.gz cgit-main.zip |
Diffstat (limited to 'git-shell-commands/create-repo')
-rwxr-xr-x | git-shell-commands/create-repo | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/git-shell-commands/create-repo b/git-shell-commands/create-repo index b5c6262..3a85514 100755 --- a/git-shell-commands/create-repo +++ b/git-shell-commands/create-repo @@ -8,14 +8,18 @@ if test "${#}" -lt 1 || test "${#}" -gt 2; then fi REPO_NAME="${1}" -REPO_SECTION="${2:-uncategorized}" -REPO_DIR="/srv/git/repos/${REPO_NAME}.git" - if ! [[ "${REPO_NAME}" =~ ^[a-zA-Z0-9_-]+$ ]]; then printf "%s\n" "[err] repository name can only contain letters, numbers, underscores, and hyphens" exit 1 fi +REPO_SECTION="${2:-uncategorized}" +if ! [[ "${REPO_SECTION}" =~ ^[a-zA-Z0-9_-]+$ ]]; then + printf "%s\n" "[err] section can only contain letters, numbers, underscores, and hyphens" + exit 1 +fi + +REPO_DIR="/srv/git/repos/${REPO_NAME}.git" if test -d "${REPO_DIR}"; then printf "%s\n" "[err] repository ${REPO_NAME}.git already exists at ${REPO_DIR}" exit 1 |