#!/bin/sh set -e if [ -z "$1" ]; then echo "Usage: new [REPO_NAME]" echo "Tip: prefix with '.' to make private (e.g. new .myrepo)" exit 1 fi REPO="$1" REPO_PATH="$HOME/$REPO.git" if [ -d "$REPO_PATH" ]; then echo "Repository $REPO already exists" exit 1 fi git init --bare "$REPO_PATH" echo "" > "$REPO_PATH/description" chown -R git:git "$REPO_PATH" if [ "${REPO#.}" = "$REPO" ]; then chmod -R 2755 "$REPO_PATH" else chmod -R 2700 "$REPO_PATH" fi echo "Created repository $REPO" echo "Clone: git@forge.jan.systems:$REPO.git" if [ "${REPO#.}" = "$REPO" ]; then echo "Web: https://forge.jan.systems/$REPO.git" fi