-
Notifications
You must be signed in to change notification settings - Fork 7
/
initialize-project
executable file
·68 lines (59 loc) · 1.52 KB
/
initialize-project
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
#!/bin/bash
# Initializes the JSpecify reference checker project by downloading required
# sibling projects.
#
# USAGE
#
# initialize-project
#
# ENVIRONMENT VARIABLES
#
# Set SHALLOW=1 to clone sibling projects at depth 1.
#
# This script automatically tries to download your fork of
# jspecify/checker-framework, jspecify/jspecify, or jspecify/jdk, if they exist.
# It uses the URL of the origin remote (the default remote created when cloning
# a repo) to determine that.
#
# If that doesn't work, you can set the FORK environment value to the Git URL
# that contains your forks. For example, FORK=git@github.com:myorg means this
# script tries to clone the following before falling back to the JSpecify repos:
#
# git@github:myorg/checker-framework.git
# git@github:myorg/jspecify.git
# git@github:myorg/jdk.git
set -eu
run() {
printf '%q ' "$@"
echo
"$@"
}
forking_org() {
if [[ -n "${FORK:-}" ]]; then
echo "${FORK}"
return
fi
dirname "$(git config --default '' --get remote.origin.url)"
}
git_clone() {
local repo="$1"
shift
if [[ -d "../${repo}" ]]; then
return
fi
local git=(git clone)
if (( "${SHALLOW:-0}" )); then
git+=(--depth 1 --single-branch)
fi
git+=("$@")
local forking_org
forking_org="$(forking_org)"
if [[ -n "${forking_org}" ]]; then
if run "${git[@]}" "${forking_org}/${repo}.git" "../${repo}"; then
return
fi
fi
run "${git[@]}" "https://github.com/jspecify/${repo}.git" "../${repo}"
}
git_clone jdk --depth 1 --single-branch
git_clone checker-framework