Skip to content

Commit

Permalink
contrib: Detect correct remote in start-backport
Browse files Browse the repository at this point in the history
Previously, the script assumed `origin` would point to the upstream
branch. For users with forked repositories this is not necessarily true,
therefore this commit auto-detects the remote name based on the git
remote url.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
gandro authored and aanm committed Feb 18, 2021
1 parent 288225a commit c7e2573
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contrib/backporting/start-backport
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright 2019 Authors of Cilium
# Copyright 2019-2021 Authors of Cilium
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,8 +33,9 @@ BRANCH=$(echo "$BRANCH" | sed 's/^v//')
# have the same conflicting branch name.
SUFFIX="${2}"

git fetch origin
if ! git branch -a | grep -q "origin/v$BRANCH$" ; then
REMOTE=$(get_remote)
git fetch "${REMOTE}"
if ! git branch -a | grep -q "${REMOTE}/v$BRANCH$" ; then
echo "usage: start-backport <branch version> [suffix]" 1>&2
echo " (detected branch $BRANCH)" 1>&2
common::exit 1
Expand All @@ -52,5 +53,5 @@ if (git --no-pager branch | grep -q "${PRBRANCH}"); then
common::exit 1
fi

git checkout -b "${PRBRANCH}" origin/v$BRANCH
git checkout -b "${PRBRANCH}" "${REMOTE}/v${BRANCH}"
contrib/backporting/check-stable $BRANCH v$BRANCH-backport-$DATE.txt

0 comments on commit c7e2573

Please sign in to comment.