forked from Carthage/workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarthage-developer-checkouts
executable file
·52 lines (39 loc) · 1.39 KB
/
carthage-developer-checkouts
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
#!/bin/bash
#
# This script replaces Carthage checkouts with symlinks pointed inside the
# parent directory (..), useful for developing dependencies in coordination with
# the parent project, while avoiding the need for submodules.
#
# Usage:
# cd ProjectFolder && /path/to/carthage-developer-checkouts
mkdir -p "Carthage/Checkouts/"
parent_dir=$(dirname "$PWD")
sed -E 's/(github|git) \"[^\/]+\/([^\"]+)\" \"([^\"]+)\"/\2 \3/g' Cartfile.resolved | while read line
do
read -a array <<< "$line"
dependency=${array[0]}
version=${array[1]}
dependency_dir="$parent_dir/$dependency"
checkout_dir="Carthage/Checkouts/$dependency"
echo "*** Setting up $dependency"
if [ -d "$dependency_dir/.git" ]
then
pushd "$dependency_dir" >/dev/null
git rev-parse "$version^{commit}" >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo -e "\tFetching"
git fetch --prune --quiet || exit $?
fi
echo -e "\tChecking out $version"
git checkout --quiet "$version" || exit $?
# TODO: Update submodules
popd >/dev/null
echo -e "\tSymlinking $checkout_dir -> $dependency_dir"
rm -rf "$checkout_dir" || exit $?
ln -s "$dependency_dir" "$checkout_dir" || exit $?
else
echo -e "\tWarning: $dependency has not yet been cloned to $dependency_dir, skipping symlink."
fi
echo
done