aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bin/gitAddUpstream.sh
blob: a91f2be275457b4c19bcd59f8e0a397092b5bce6 (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
33
34
35
36
37
#!/bin/sh

if [ $# -lt 4 ]; then
  echo "ERROR incorrect number of parameters"
  echo "Usage:"
  echo "   $0 <repo_name> <repo_directory> <remote_name> <remote_url>"
  echo
  echo "$0 adds a remote named <remote_name> to repository <repo_name> located"
  echo "in directory <repo_directory>. The remote will point towards <remote_url>"
  echo "If <remote_name> already exits nothing will be done."
  exit 1
fi

REPO_NAME=$1
REPO_DIR=$2
REMOTE_NAME=$3
REMOTE_URL=$4

if [ ! -d $REPO_DIR ]; then
  echo "ERROR running $0"
  echo "      Directory $REPO_DIR not found"
  exit 1
fi

echo "###################################################################"
echo "# Updationg remote $REMOTE_NAME for $REPO_NAME"

cd $REPO_DIR

git remote add $REMOTE_NAME $REMOTE_URL > /dev/null 2>&1
if [ $? -ne 0 ]; then
  echo "# Skipped - not needed"
  exit 0
fi

echo "# Added $REMOTE_URL"
exit 0