stagit-scripts

Personal companion scripts for stagit
git clone _git@git.zakaria.org/stagit-scripts.git
Log | Files | Refs | README

stagit-newrepo (767B)


      1 #!/bin/sh
      2 # Author: Cale "poptart" Black
      3 # Modified by: zakaria @ zakaria.org
      4 # License: MIT
      5 # Usage: stagit-newrepo <name> [desc] [author]
      6 
      7 set -eu
      8 
      9 . /var/git/config.rc
     10 
     11 log() {
     12 	printf '%s\n' "$*" >&2
     13 }
     14 die() {
     15 	log "error: $*"
     16 	printf 'exiting...\n'
     17 	exit 1
     18 }
     19 
     20 REPO="$1"
     21 DESC="${2:-$DEFAULT_DESC}"
     22 OWNER="${3:-$DEFAULT_OWNER}"
     23 
     24 if [ -z "$REPO" ]; then
     25 	die "no repo name provided"
     26 fi
     27 
     28 REPO_PATH="${GIT_REPOS}/${REPO}.git"
     29 
     30 git init --bare "$REPO_PATH"
     31 cp "${GIT_HOME}/template/post-receive" "${REPO_PATH}/hooks/post-receive"
     32 echo "${CLONE_URI}/${REPO}.git" > "${REPO_PATH}/url"
     33 echo "$OWNER" > "${REPO_PATH}/owner"
     34 echo "$DESC" > "${REPO_PATH}/description"
     35 
     36 chmod u+x "${REPO_PATH}/hooks/post-receive"
     37 mkdir "${WWW_HOME}/${REPO}"
     38 
     39 /usr/local/bin/stagit-gen-index