-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit-bare-repo.sh
executable file
·46 lines (41 loc) · 1.25 KB
/
git-bare-repo.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#
# Simple shell script to create a bare github repo and configure it for
# SLAC EPICS module development
#
this_script=`readlink -f ${BASH_SOURCE[0]}`
eco_tools_dir=`readlink -f $(dirname $this_script)`
if [ "$1" == "--version" ]; then
grep eco_tools_version $eco_tools_dir/eco_version.py
exit 1
fi
if [ -z "$1" -o "$1" == "-h" -o "$1" == "--help" ]; then
echo "Usage: ./git-bare-repo.sh /path/to/your_repo/repo_name.git"
echo "For new EPICS modules, you can just use relative pathname module_name.git"
echo "For all other repos, please specify an absolute repo pathname."
exit 1
fi
GIT_DIR=$1
if [ -d $GIT_DIR ]; then
echo "Error: $GIT_DIR already exists!"
exit 1
fi
if [ "$GIT_DIR" == "${GIT_DIR%%.git}" ]; then
GIT_DIR=${GIT_DIR}.git
fi
# Make bash exit if any of the following cmds fail
set -e
# Find the git repo templates
if [ -z "$GIT_TOP" ]; then
GIT_TOP=/afs/slac/g/cd/swe/git/repos
fi
PARENT_DIR=$GIT_TOP/package/epics/modules
TEMPLATES=$GIT_TOP/package/epics/epics-git-templates-git/templates
cd $PARENT_DIR
if [ -d $GIT_DIR ]; then
echo "Error: $GIT_DIR already exists!"
exit 1
fi
# Create a bare it repo using our local templates directory
git init --bare --template=$TEMPLATES $GIT_DIR
echo Successfully created bare repo $GIT_DIR