You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 439ec14
Browse filesBrowse the repository at this point in the historyBrowse files
# Create a branch in the fork, pointing at the upstream repository's branch head. GitHub keeps a fork and its
161
+
# upstream in one object network, so the upstream's commit is addressable through the fork and no clone,
162
+
# fetch or push is involved. 'gh repo sync' can only fast-forward a branch that already exists.
163
+
createBranch() {
164
+
local upstream="${1}" fork="${2}" branch="${3}"
165
+
local sha messages
166
+
167
+
sha="$(gh api "repos/${upstream}/git/ref/heads/${branch}" --jq '.object.sha' 2>&1)"
168
+
if [[ $? -ne 0 ]]; then
169
+
printf " ❌ %s\n" "${ANSI_LIGHT_RED}${branch} — exists neither in the fork nor in '${upstream}'${ANSI_NOCOLOR}"
170
+
printf "::error title=%s::%s\n" "Create ${fork}:${branch}" "Branch '${branch}' exists neither in the fork '${fork}' nor in the upstream repository '${upstream}'."
171
+
return 1
172
+
fi
173
+
174
+
messages="$(gh api --method POST "repos/${fork}/git/refs" --field "ref=refs/heads/${branch}" --field "sha=${sha}" 2>&1)"
175
+
if [[ $? -ne 0 ]]; then
176
+
printf " ❌ %s\n" "${ANSI_LIGHT_RED}${branch} — couldn't be created from ${upstream}@${sha:0:7}${ANSI_NOCOLOR}"
printf " ❌ %s\n" "${ANSI_LIGHT_RED}${branch} — doesn't exist in the fork${ANSI_NOCOLOR}"
272
+
printf " ↪ %s\n" "${ANSI_LIGHT_RED}enable 'create-missing-branches' to create it${ANSI_NOCOLOR}"
273
+
printf "::error title=%s::%s\n" "Synchronize ${upstream} ⇒ ${TARGET_ORGANISATION}/${repository}:${branch}" "Branch '${branch}' doesn't exist in the fork. Enable 'create-missing-branches' to create it from '${upstream}'."
0 commit comments