i (709B) - raw


      1 #!/bin/sh
      2 # create a new repository (private by default)
      3 
      4 # check number of params
      5 [ $# -ne 1 ] && echo "Usage: i repo[.git]" && exit 1
      6 
      7 # set the repository name, adding .git if necessary
      8 p=$(echo "$1" | sed 's/\.git$\|$/.git/i')
      9 
     10 [ -e "$p" ] && echo "$p is already a file or directory." && exit 1
     11 
     12 curr_dir="$(dirname "$(realpath "$0")")"
     13 
     14 # create and initialise the repository
     15 mkdir "$p" && \
     16     cd "$p" && \
     17     git --bare init
     18 ln -sf "/usr/local/share/doc/stagit/example_post-receive.sh" "hooks/post-receive"
     19 ln -sf "$curr_dir/non-interactive/post-update-hook" "hooks/post-update"
     20 
     21 echo "Oscar Benedito" > "owner"
     22 echo "https://git.oscarbenedito.com/${p%.git}" > "url"
     23 echo "${p%.git}" > "description"