@@ -79,6 +79,33 @@ while getopts "r:t:b:" o; do
79
79
done
80
80
shift $(( OPTIND - 1 ))
81
81
82
+ # default from prow env if unset from args
83
+ # https://docs.prow.k8s.io/docs/jobs/#job-environment-variables
84
+ # TODO: handle batch PR testing
85
+
86
+ if [[ -z " ${target:- } " && -n " ${PULL_PULL_SHA:- } " ]]; then
87
+ target=" ${PULL_PULL_SHA} "
88
+ fi
89
+ # target must be a something that git can resolve to a commit.
90
+ # "git rev-parse --verify" checks that and prints a detailed
91
+ # error.
92
+ if [[ -n " ${target} " ]]; then
93
+ target=" $( git rev-parse --verify " ${target} " ) "
94
+ fi
95
+
96
+ if [[ -z " ${base} " && -n " ${PULL_BASE_SHA:- } " && -n " ${PULL_PULL_SHA:- } " ]]; then
97
+ if ! base=" $( git merge-base " ${PULL_BASE_SHA} " " ${PULL_PULL_SHA} " ) " ; then
98
+ echo >&2 " Failed to detect base revision correctly with prow environment variables."
99
+ exit 1
100
+ fi
101
+ elif [[ -z " ${base} " ]]; then
102
+ if ! base=" $( git merge-base origin/master " ${target:- HEAD} " ) " ; then
103
+ echo >&2 " Could not determine default base revision. -r must be used explicitly."
104
+ exit 1
105
+ fi
106
+ fi
107
+ base=" $( git rev-parse --verify " ${base} " ) "
108
+
82
109
# Check specific directory or everything.
83
110
targets=(" $@ " )
84
111
if [ ${# targets[@]} -eq 0 ]; then
@@ -93,22 +120,6 @@ if [ ${#targets[@]} -eq 0 ]; then
93
120
done
94
121
fi
95
122
96
- # Must be a something that git can resolve to a commit.
97
- # "git rev-parse --verify" checks that and prints a detailed
98
- # error.
99
- if [ -n " ${target} " ]; then
100
- target=" $( git rev-parse --verify " ${target} " ) "
101
- fi
102
-
103
- # Determine defaults.
104
- if [ -z " ${base} " ]; then
105
- if ! base=" $( git merge-base origin/master " ${target:- HEAD} " ) " ; then
106
- echo >&2 " Could not determine default base revision. -r must be used explicitly."
107
- exit 1
108
- fi
109
- fi
110
- base=" $( git rev-parse --verify " ${base} " ) "
111
-
112
123
# Give some information about what's happening. Failures from "git describe" are ignored
113
124
# silently, that's optional information.
114
125
describe () {
0 commit comments