-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_from_upstream
executable file
·44 lines (36 loc) · 1.17 KB
/
update_from_upstream
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
#!/bin/bash
set -e
cd "$(dirname "$0")/.."
if [[ $(basename "$PWD") == "swagger" ]]; then
echo "This command is only used in langauge specific repositories"
exit 1
fi
# Gets content at $1 and puts it into $2, automatically chmod +x if $2 is the
# script dir.
get() {
curl --fail --silent --show-error "$1" > "$2"
if [[ $(dirname "$2") == "script" ]]; then
chmod +x "$2"
fi
}
# Gets a file $1 from the upstream repo and places it in the same location.
get_upstream() {
get "https://raw.githubusercontent.com/docraptor/docraptor-swagger/master/$1" "$1"
}
# Main entry point, wrapped in a function so that bash can handle replacing
# this file while executing it.
update() {
original=$(md5 script/update_from_upstream)
get_upstream script/update_from_upstream
if [[ $(md5 script/update_from_upstream) != "$original" ]]; then
echo "Detected updated update_from_upstream command, running again"
script/update_from_upstream
exit 0 # recursive call above handled everything
fi
get_upstream docraptor.yaml
get_upstream .swagger-revision
get_upstream script/swagger
script/swagger # download repo, etc.
get_upstream script/generate_language
}
update