1
1
#! /usr/bin/env bash
2
2
3
- cph=$( git rev-list -n 1 CHERRY_PICK_HEAD 2> /dev/null)
4
-
5
3
set -o errexit
6
4
set -o pipefail
7
5
@@ -36,20 +34,44 @@ function pop() {
36
34
fi
37
35
printf ' popping: %s\n' " ${rc} "
38
36
39
- if [[ ! $cph ]]; then
40
- git cherry-pick --allow-empty --keep-redundant-commits -Xsubtree=" ${subtree_dir} " " ${rc} "
41
- else
42
- if [[ $cph != " ${rc} " ]]; then
43
- printf ' unexpected CHERRY_PICK_HEAD:\ngot %s\nexpected: %s\n' " ${cph} " " ${rc} "
44
- exit
45
- fi
46
- printf ' cherry-pick in progress for %s\n' " ${cph} "
47
- git add .
37
+ # Note: this may require a more up-to-date git version
38
+ if ! git cherry-pick --allow-empty --keep-redundant-commits -Xsubtree=" ${subtree_dir} " " ${rc} " ; then
39
+ # Always blast away the vendor directory given OLM/registry still commit it into source control.
40
+ git rm -rf " ${subtree_dir} " /vendor 2> /dev/null || true
41
+
42
+ # TODO: handle the case where there's a single merge conflict.
43
+ # TODO: handle root go.mod merge conflicts!
44
+ # TODO: maybe use a while loop here?
45
+ # TODO: verify there's no remaining merge conflicts
46
+ num_conflicts=$( git diff --name-only --diff-filter=U --relative | wc -l)
47
+ while [[ $num_conflicts != 0 ]] ; do
48
+ file=$( git diff --name-only --diff-filter=U --relative)
49
+
50
+ if [[ $file == * " go.mod" * ]]; then
51
+ git diff " ${subtree_dir} " /go.mod
52
+
53
+ git checkout --theirs " ${subtree_dir} " /go.mod
54
+ pushd " ${subtree_dir} "
55
+ # Note: handle case where this fails. does this update the root module too?
56
+ go mod tidy
57
+ # TODO: double-check there's no remaining markers via git diff --check: <https://stackoverflow.com/questions/3065650/whats-the-simplest-way-to-list-conflicted-files-in-git>?
58
+ git add go.mod go.sum
59
+ popd
60
+ else
61
+ git checkout --theirs " $file "
62
+ git diff " $file "
63
+ git add " $file "
64
+ fi
65
+
66
+ num_conflicts=$( git diff --name-only --diff-filter=U --relative | wc -l)
67
+ echo " number of merge conflicts remaining: $num_conflicts "
68
+ done
48
69
49
70
if [[ -z $( git status --porcelain) ]]; then
50
71
git commit --allow-empty
51
72
else
52
- git cherry-pick --continue
73
+ echo " Current cherry pick status: $( git status --porcelain) "
74
+ git -c core.editor=true cherry-pick --continue
53
75
fi
54
76
fi
55
77
@@ -59,8 +81,9 @@ function pop() {
59
81
# 3. Ammend commit
60
82
# 4. Remove from cherrypick set
61
83
make vendor
84
+ # TODO: make this check smarter and avoid manifest generation when it's not needed.
62
85
make manifests
63
- git add " ${subtree_dir} " " ${KNOWN_GENERATED_PATHS [@]} "
86
+ git add " ${subtree_dir} " " ${ROOT_GENERATED_PATHS [@]} "
64
87
git status
65
88
git commit --amend --allow-empty --no-edit --trailer " Upstream-repository: ${remote} " --trailer " Upstream-commit: ${rc} "
66
89
@@ -72,9 +95,19 @@ function pop() {
72
95
(( -- remaining )) || true
73
96
printf ' %d picks remaining (pop_all=%s)\n' " ${remaining} " " ${pop_all} "
74
97
98
+ # no changes added to commit (use "git add" and/or "git commit -a")
99
+ # [sync-2022-08-09 11f50a83b] add grokspawn to OWNERS (#2833)
100
+ # Author: grokspawn <[email protected] >
101
+ # Date: Tue Aug 9 13:44:11 2022 -0500
102
+ # 1 file changed, 4 insertions(+), 2 deletions(-)
103
+ # 0 picks remaining (pop_all=true)
104
+ # ./scripts/../scripts/sync_pop_candidate.sh: line 108: unexpected EOF while looking for matching `''
105
+ # make: *** [Makefile:191: sync] Error 2
106
+ echo " Checking whether there's any remaining cherry picks"
75
107
if [[ $pop_all == ' true' ]] && (( remaining > 0 )) ; then
76
108
pop
77
109
fi
110
+ echo " Done"
78
111
}
79
112
80
113
pop
0 commit comments