Skip to content

Commit

Permalink
Crave: switch to the correct branch for the PR (#2124)
Browse files Browse the repository at this point in the history
* Switch to the correct branch for the PR

PRs have remote refs.
That remote ref will not be automatically fetched when we fetch origin.
So how do we fetch it?
1. first fetch the actual remote reference and map it to a "local ref".
   This is done using git fetch <remote-ref>:<name for local ref>
2. Then we switch to the ref: git checkout <name for local ref>

This sets the state of the local clone to what the PR expects it to be
  • Loading branch information
uvatbc authored Dec 8, 2023
1 parent 5f67d4a commit a2f5e9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/tests-via-crave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
- name: Crave clone sources
run: crave clone create --projectID 39 /crave-devspaces/pipeline/runs/${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}
- name: Checkout the correct branch
run: git -C /crave-devspaces/pipeline/runs/${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}/solr checkout ${GITHUB_HEAD_REF} || echo "${GITHUB_HEAD_REF} not present on solr repo, staying at main"
continue-on-error: true
run: |
git -C /crave-devspaces/pipeline/runs/${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}/solr fetch origin ${GITHUB_REF}:${GITHUB_REF}
git -C /crave-devspaces/pipeline/runs/${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}/solr checkout ${GITHUB_REF}
- name: Initialize, build, test
run: |
cd /crave-devspaces/pipeline/runs/${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}/solr
Expand Down

0 comments on commit a2f5e9e

Please sign in to comment.