-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoy-upload
executable file
·67 lines (58 loc) · 1.64 KB
/
hoy-upload
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
#!/bin/bash
source /usr/lib/ayer/functions.sh || exit 1
hoy_init
target_feature=$(git rev-parse --abbrev-ref HEAD)
usage="usage: $(basename $0) [-p|--pretend] [-f|--force] [-i|--ignore]"
opt_pretend=n
opt_force=n
opt_ignore=n
while [ $# -gt 0 ]; do
case "$1" in
-p|--pretend)
opt_pretend=y
shift
;;
-f|--force)
opt_force=y
shift
;;
-i|--ignore)
opt_ignore=y
shift
;;
-h|--help)
echo "$usage"
exit 0
;;
*)
die "$usage"
;;
esac
done
target_branch=$(get_trunk "$target_feature")
username=$(get_username)
upload_type=for
{ git submodule -q foreach 'echo $name'; echo .; } | while read repo_path; do
cd $hoy_top/$repo_path
local_commit=$(git rev-parse HEAD)
remote_commit=$(git rev-parse remotes/origin/$target_branch || true)
if [ "$local_commit" == "$remote_commit" ]; then
continue
fi
published_ref=refs/published/$target_feature
if [ "$opt_ignore" == n ] && git rev-parse $published_ref &>/dev/null; then
difference=$(git rev-list $published_ref..HEAD)
if [ -z "$difference" ]; then
continue
fi
fi
if [ "$opt_pretend" == y ]; then
echo "changes for $repo_path"
git cherry -v remotes/origin/$target_branch HEAD
else
if ! git push origin HEAD:refs/$upload_type/$target_branch/$target_feature; then
[ "$opt_force" == y ] || die "cannot publish changes for $repo_path"
fi
git update-ref $published_ref HEAD
fi
done