Commit 8480cf9f authored by Fabian Müller's avatar Fabian Müller
Browse files

Replace mr-fetch-target-branch with shell script

parent da340e5a
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -66,13 +66,6 @@ stages:
    echo "Commit time was $CI_COMMIT_TIMESTAMP"
    ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression

.mr-fetch-target-branch: &mr-fetch-target-branch
  # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
  # depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later
  - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME || true
  # needed when depth is lower than the number of commits in the branch
  - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:$CI_MERGE_REQUEST_TARGET_BRANCH_NAME

.mr-get-target-commit: &mr-get-target-commit # compare to last target branch commit before pipeline was created
  - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H)

@@ -116,8 +109,8 @@ stages:
  - source_branch_commit_sha=$(git rev-parse HEAD)

  ### checkout version to compare against
  - *mr-fetch-target-branch
  - *mr-get-target-commit
  - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/mr-fetch-target-branch.sh
  - target_commit="$("$CI_PROJECT_DIR"/.gitlab-ci/snippets/mr-get-target-commit.sh)"
  - git checkout $target_commit
  - echo "Building reference codec at commit $target_commit"

@@ -894,8 +887,8 @@ split-rendering-pytest-on-merge-request:
    # store the current commit hash
    - source_branch_commit_sha=$(git rev-parse HEAD)

    - *mr-fetch-target-branch
    - *mr-get-target-commit
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/mr-fetch-target-branch.sh
    - target_commit="$("$CI_PROJECT_DIR"/.gitlab-ci/snippets/mr-get-target-commit.sh)"
    - git checkout $target_commit
    - echo "Building reference codec at commit $target_commit"

+11 −0
Original line number Diff line number Diff line
#! /bin/bash

set -euo pipefail

cd "${CI_PROJECT_DIR}"

# first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
# depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later
git branch -D "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" || true
# needed when depth is lower than the number of commits in the branch
git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME":"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"