-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-to-github.sh
executable file
·105 lines (90 loc) · 2.6 KB
/
export-to-github.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
#!/bin/bash
# vim: sw=4
set -o errexit -o nounset -o pipefail -o noglob
githubUrl='https://github.com/zibamira/microtubulestitching.git'
githubLocal='/tmp/github-zibamira-microtubulestitching'
pkgs='dai mpir hxalignmicrotubules'
logPaths="${pkgs} microtubulestitching"
toplevelFiles='
AUTHORS.md
LICENSE.md
README-technical.md
README.md
export-to-github.sh
'
main() {
warn=
echo "~~~ FETCH ${githubLocal}"
if [ -e ${githubLocal} ]; then
[ "$(git -C ${githubLocal} config remote.origin.url)" = "${githubUrl}" ] ||
die "Existing ${githubLocal} with wrong remote.origin.url; expected ${githubUrl}."
gitgh fetch
gitgh checkout master
gitgh reset --hard origin/master
else
git clone ${githubUrl} ${githubLocal}
fi
gitgh show -s
echo
echo "~~~ CONFIG"
prev=$(gitgh show -s --pretty=%s | cut -d '@' -f 2)
echo "Previous version at GitHub: ${prev}"
git rev-parse -q --verify refs/tags/${prev} >/dev/null 2>&1 ||
die "Missing tag ${prev}"
this=$(git describe | cut -d - -f 1,2 | egrep 'zibedition-\d{4}.\d{2}')
echo "Latest local version: ${this}"
git rev-parse -q --verify refs/tags/${this} >/dev/null 2>&1 ||
die "Missing tag ${this}"
echo
echo "Relevant commits: previous..latest -- ${logPaths}"
git -C .. --no-pager log --oneline --reverse ${prev}..${this} -- ${logPaths}
echo
echo "shortlog:"
git -C .. log ${prev}..${this} -- ${logPaths} | git --no-pager shortlog
echo
echo "~~~ COPY ${githubLocal}"
(
cd ${githubLocal} &&
git ls-files -z | xargs -0 rm -f
)
for pkg in ${pkgs}; do
dst="${githubLocal}/${pkg}"
echo "${dst}..."
mkdir -p "${dst}"
git -C .. archive ${this}:${pkg} | gtar -C "${dst}" -xf -
done
for top in ${toplevelFiles}; do
dst="${githubLocal}/${top}"
echo "mv ${dst}"
mv "${githubLocal}/hxalignmicrotubules/${top}" "${dst}" || {
echo "WARNING: ignoring mv error."
warn=t
}
done
echo
echo "~~~ COMMIT"
(
cd ${githubLocal} &&
echo '*.am filter=silo -text' >'.gitattributes' &&
git silo init
)
gitgh add -- .
gitgh commit -s -S -m \
"Update to zib-amira@${this}
Relevant commits since the previous export:
$(git -C .. log --oneline --reverse ${prev}..${this} -- ${logPaths} | sed -e 's/^/ /')
"
if test ${warn}; then
echo
echo 'There have been warnings!'
echo
fi
}
gitgh() {
git -C ${githubLocal} "$@"
}
die() {
printf >&2 'Error: %s\n' "$1"
exit 1
}
main "$@"