aboutsummaryrefslogtreecommitdiff
path: root/git-shell-commands/new-project
blob: 3ef14f452c63fe3c90f61496da55e1cb9d215f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# this script allows the creation of projects over ssh on git server
# public repos will get a public.conf containing the remote
# private repos will just exist on the server
#
# USAGE:
# ssh git@<host> new-project 
# - follow the prompts

REMOTE_BASE_URL = "git@treybastian.com:repos/"
echo "oh look you are starting a project you won't finish again."
echo "What is your projects name?"
read PROJECT_NAME
if [[ $PROJECT_NAME!=*.git ]]; then
  PROJECT_NAME="${PROJECT_NAME}.git"
fi
read -p "Is this public?" -n 1 -r
echo

git --bare init "${PROJECT_NAME}"

if [[ $REPLY =~ ^[Yy]$ ]]; then
  touch "${PROJECT_NAME}/public.conf" 
  echo "${REMOTE_BASE_URL}/${PROJECT_NAME}" >> "${PROJECT_NAME}/public.conf"
  ssh git@treybastian.com new-repo "repos/${PROJECT_NAME}"
fi

echo "git url: ${USER}@${HOSTNAME}:${PROJECT_NAME}"
if [[ $REMOTE_URL ]]; then
  echo "public repo: ${REMOTE_BASE_URL}/${PROJECT_NAME}"
fi
#vim: filetype=bash