-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate_from.sh
103 lines (90 loc) · 2.41 KB
/
update_from.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
#!/bin/bash
set -e
if [ $# -eq 0 ]
then
echo "No arguments supplied, require target branch and source branch."
exit 1
fi
if [ $# -eq 1 ]
then
echo "Only one argument supplied, require target branch and source branch."
exit 1
fi
# Ensure we are in the correct directory.
cd $(cd "$(dirname "$0")"; pwd)
# Save the current branch.
current_branch=$(git symbolic-ref -q HEAD)
current_branch=${current_branch##refs/heads/}
current_branch=${current_branch:-HEAD}
# Checkout the target branch.
git checkout $1
# Get a list of all files.
source=$(find "source" -type f -print)
testbench=$(find "testbench" -type f -print)
tests=$(find "tests" -type f -print)
checks=$(find "checks" -type f -print)
# Checkout back to the current branch.
git checkout ${current_branch}
# Try and checkout the build system files to ensure they are up to date.
git checkout $2 compile.sh
git checkout $2 memcheck.supression
git checkout $2 CMakeLists.txt
# Try and checkout the README.md.
git checkout $2 README.md
# Try and checkout all files found in the target branch from the source branch.
for file in ${source}
do
if [ -f "${file}" ]
then
echo "Checking '${file}'..."
if git cat-file -e $2:${file} > /dev/null 2>&1
then
echo "Adding '${file}'."
git checkout $2 ${file}
else
echo "File '${file}' no longer exists on target branch."
fi
fi
done
for file in ${testbench}
do
if [ -f "${file}" ]
then
echo "Checking '${file}'..."
if git cat-file -e $2:${file} > /dev/null 2>&1
then
echo "Adding '${file}'."
git checkout $2 ${file}
else
echo "File '${file}' no longer exists on target branch."
fi
fi
done
for file in ${tests}
do
if [ -f "${file}" ]
then
echo "Checking '${file}'..."
if git cat-file -e $2:${file} > /dev/null 2>&1
then
echo "Adding '${file}'."
git checkout $2 ${file}
else
echo "File '${file}' no longer exists on target branch."
fi
fi
done
for file in ${checks}
do
if [ -f "${file}" ]
then
echo "Checking '${file}'..."
if git cat-file -e $2:${file} > /dev/null 2>&1
then
echo "Adding '${file}'."
git checkout $2 ${file}
else
echo "File '${file}' no longer exists on target branch."
fi
fi
done