diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-03 11:41:33 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:36:45 -0700 |
| commit | 024ae3365ffa40b5d0b117577c552587b258ca7a (patch) | |
| tree | a2907f5a9018009e55b0d1690c3210844b74af30 /roles/obsd_git/files/git-shell-commands | |
| download | site-configs-024ae3365ffa40b5d0b117577c552587b258ca7a.zip | |
Initial Commit
Diffstat (limited to 'roles/obsd_git/files/git-shell-commands')
| -rw-r--r-- | roles/obsd_git/files/git-shell-commands/create | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/roles/obsd_git/files/git-shell-commands/create b/roles/obsd_git/files/git-shell-commands/create new file mode 100644 index 0000000..db38900 --- /dev/null +++ b/roles/obsd_git/files/git-shell-commands/create @@ -0,0 +1,27 @@ +#!/bin/sh +set -e + +main() { + repo="$1" + desc="$2" + if [ -z "$repo" ]; then + echo "Usage: provide a repository name" >&2 + exit 1 + fi + + repo_name=$(basename "$repo" .git) + repo_path="/var/www/pub/git/$repo_name.git" + + if [ ! -d "$repo_path" ]; then + echo "Creating bare repository: $repo_name.git" + git init --bare --initial-branch=main "$repo_path" + chown -R git:git "$repo_path" + + if [ -n "$desc" ]; then + # cgit will lookup the git repository description via the git config. + git -C "$repo_path" config gitweb.description "$desc" + fi + fi +} + +main "$@" |