forked from insoshi/insoshi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_insoshi_local.sh
114 lines (90 loc) · 2.7 KB
/
configure_insoshi_local.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
# Automatic configuration for local Insoshi Git repository
#
# Requirements:
# 1. Working git installation
# 2. Fork of insoshi repository on GitHub
#
# Usage:
# configure_insoshi_local [GitHub Account Name]
#
# This script will create a local clone of the official Insoshi Git
# repository located on GitHub. The specified Insoshi fork will be
# added as an addtional remote repository and a new branch created to
# track local development.
#
# Verify number of arguments to script
#
if [ $# -ne "1" ]
then
echo "Usage: configure_insoshi_local [GitHub Account Name]"
exit 1
fi
GITHUB_ACCOUNT=`echo $1`
MAIN_REPOSITORY=`echo git://github.com/insoshi/insoshi.git`
REMOTE=`echo $GITHUB_ACCOUNT`
REMOTE_URL=`echo [email protected]:$GITHUB_ACCOUNT/insoshi.git`
BRANCH=`echo $GITHUB_ACCOUNT`
# Error handling function
catch_error() {
if [ $1 -ne "0" ]
then
echo "ERROR encountered $2"
exit 1
fi
}
# Clone official insoshi repository
#
# This sets the local master branch to be equal to the official insoshi
# master
#
echo "Cloning official insoshi repository..."
git clone $MAIN_REPOSITORY
catch_error $? "cloning official insoshi repository"
echo
# Change directory into local insoshi repository
#
cd insoshi
# Create a local branch that tracks the forked master branch
#
echo "Creating local tracking branch for edge..."
git branch --track edge origin/edge
catch_error $? "creating local tracking branch for edge"
# Create a local branch based off edge
#
echo "Creating local branch $BRANCH..."
git branch $BRANCH edge
catch_error $? "creating local branch $BRANCH"
git checkout $BRANCH
catch_error $? "checking out local branch $BRANCH"
echo
# Add forked repository as a remote repository connection
#
# The GitHub account name will be used to refer to this repository
#
echo "Adding remote connection to forked repository..."
git remote add $REMOTE $REMOTE_URL
catch_error $? "adding remote $REMOTE"
echo
# Fetch branch information
#
echo "Fetching remote branch information..."
git fetch $REMOTE
catch_error $? "fetching branches from remote $REMOTE"
echo
# Create the matching remote branch on the forked repository
#
# We need to explicitly create the branch via a push command
#
echo "Pushing local branch $BRANCH to remote $REMOTE..."
git push $REMOTE $BRANCH:refs/heads/$BRANCH
catch_error $? "pushing local branch $BRANCH to remote $REMOTE"
echo
# Configure the remote connection for the local branch
#
echo "Configuring remote connection for local branch $BRANCH..."
git config branch.$BRANCH.remote $REMOTE
catch_error $? "configuring remote $REMOTE for local branch $BRANCH"
git config branch.$BRANCH.merge refs/heads/$BRANCH
catch_error $? "configuring merge tracking for local branch $BRANCH"
exit 0