Commit 449657db authored by Jan Kiene's avatar Jan Kiene
Browse files

adapt branch-is-up-to-date-with-target-pre script to use ivas-codec repo

parent 3d5e9cd3
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -30,22 +30,22 @@

set -euxo pipefail

float_ref_branchname="ivas-float-update"
URL_FLOAT_REPO="https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git"
FLOAT_DIR="ivas-codec"

float_ref_branchname_in_ivas_codec="main"
exit_code_follows_naming_conventions=0
# if branch does not follow the convention, there will be a printout which is irrelevant here, so redirect it to null
bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/branch-follows-porting-naming-convention.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME >>/dev/null || exit_code_follows_naming_conventions=$?
# if this branch follows the naming convetions, we can try to get the corresponding float MR branch
# if this branch does NOT follow the porting naming convention, the float ref is just ivas-float-update, so skip everything
if [[ "$exit_code_follows_naming_conventions" == "0" ]]; then
  float_ref_branchname=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME)
  float_ref_branchname_in_ivas_codec=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME)
fi

# fetch all needed branches
# fetch merge target and check if we are up-to-date
git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git fetch origin ivas-float-update
git fetch origin "$float_ref_branchname"

# then check if we are behind the merge target
commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)"
if [ $commits_behind_count -ne 0 ]; then
  echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update."
@@ -60,11 +60,25 @@ MERGE_TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAM
echo "MERGE_TARGET_COMMIT is $MERGE_TARGET_COMMIT"
echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE"

MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname")"
set -x

# to get the commit SHAs for the float reference branches, we need to clone the repo here
git clone $URL_FLOAT_REPO $FLOAT_DIR

# below here we will be in the float repo!
cd $FLOAT_DIR

# only fetch ref branch, main is the default branch
git fetch origin "$float_ref_branchname_in_ivas_codec"

# stop echoing from here on, this is anyway only dbg printout
set +x

MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")"
echo "MERGE_SOURCE_FLOAT_REF_COMMIT is $MERGE_SOURCE_FLOAT_REF_COMMIT"
echo "$MERGE_SOURCE_FLOAT_REF_COMMIT" >"$MERGE_SOURCE_FLOAT_REF_COMMIT_FILE"

FLOAT_REF_COMMIT="$(git rev-parse "origin/ivas-float-update")"
FLOAT_REF_COMMIT="$(git rev-parse "origin/main")"
echo "FLOAT_REF_COMMIT is $FLOAT_REF_COMMIT"
echo "$FLOAT_REF_COMMIT" >"$FLOAT_REF_COMMIT_FILE"