-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresetRepo.sh
60 lines (45 loc) · 1.38 KB
/
resetRepo.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
#!/bin/bash
export WORKDIR=${GHA_WORKDIR:?"Need to set GHA_WORKDIR to writeable directory"}
if [[ ! -d "${WORKDIR}" || ! -w "${WORKDIR}" ]] ; then
echo "${WORKDIR} is not writable. Please check value of GHA_WORKDIR"
exit 0
fi
if [ $# -ne 4 ] ; then
echo "Usage: populateRepo.sh repoName repoURL protoDir" ;
echo "Example: populateRepo.sh lab00_Phillip git@github.com:UCSB-CS56-S13/lab00_Phillip.git /cs/faculty/pconrad/cs56/lab00_prototype /cs/faculty/pconrad/cs56/scratchRepos" ; exit 0
fi
export repoName=$1
export repoURL=$2
export protoDir=$3
export scratchDir=${WORKDIR}/scratch
printf "Populating repo %s... " $repoName
# " with url " $repoURL \
# " from dir " $protoDir \
# " in scratch dir " $scratchDir
mkdir -p $scratchDir; cd $scratchDir
if [ -d $scratchDir/$repoName ] ; then
printf " found repo %s ... " $repoName
else
printf " cloning repo %s... \n" $repoName
git clone -q -n $repoURL
fi
cd $repoName
export cdStatus=$?
if [ $cdStatus -ne 0 ] ; then
echo "Can't find repo $repoName -- bailing out "; exit 1
fi
git pull
rm -rvf *
cp -vr $protoDir/* .
git add .
git add -f lib/*
if [ -f $protoDir/.gitignore ] ; then
cp -v $protoDir/.gitignore .
git add .gitignore
fi
if [ -f $protoDir/.gitmodues ] ; then
cp -v $protoDir/.gitmodules .
git add .gitmodules
fi
git commit -m "Files pushed by populateRepo.sh script"
git push origin master