-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test.mk get PR branch from CLONEREFS_OPTIONS (#887)
* test.mk get PR branch from CLONEREFS_OPTIONS * add refs/heads/ to branch from CLONEREF_OPTIONS * get and use PR branch from CLONEREF_OPTIONS * trying things * trying things 2 * trying things 3 * possible solution * attempt to fix error * solution * fix non github action path --------- Co-authored-by: Matous Jobanek <[email protected]> Co-authored-by: Francisc Munteanu <[email protected]>
- Loading branch information
1 parent
76b9d37
commit febf379
Showing
1 changed file
with
6 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,29 +97,26 @@ ifeq ($(E2E_REPO_PATH),"") | |
git clone https://github.com/codeready-toolchain/toolchain-e2e.git ${E2E_REPO_PATH} | ||
ifneq ($(CI),) | ||
ifneq ($(GITHUB_ACTIONS),) | ||
$(eval BRANCH_REF = refs/heads/${GITHUB_HEAD_REF}) | ||
$(eval BRANCH_NAME = ${GITHUB_HEAD_REF}) | ||
$(eval AUTHOR_LINK = https://github.com/${AUTHOR}) | ||
else | ||
$(eval AUTHOR_LINK = $(shell jq -r '.refs[0].pulls[0].author_link' <<< $${CLONEREFS_OPTIONS} | tr -d '[:space:]')) | ||
@echo "using pull sha ${PULL_PULL_SHA}" | ||
# get branch ref of the fork the PR was created from | ||
$(eval BRANCH_REF := $(shell curl ${AUTHOR_LINK}/host-operator.git/info/refs?service=git-upload-pack --output - /dev/null 2>&1 | grep -a ${PULL_PULL_SHA} | awk '{print $$2}')) | ||
@echo "found author link ${AUTHOR_LINK}" | ||
$(eval BRANCH_NAME := $(shell jq -r '.refs[0].pulls[0].head_ref' <<< $${CLONEREFS_OPTIONS} | tr -d '[:space:]')) | ||
endif | ||
@echo "using author link ${AUTHOR_LINK}" | ||
@echo "detected branch ref ${BRANCH_REF}" | ||
@echo "detected branch ${BRANCH_NAME}" | ||
# check if a branch with the same ref exists in the user's fork of toolchain-e2e repo | ||
$(eval REMOTE_E2E_BRANCH := $(shell curl ${AUTHOR_LINK}/toolchain-e2e.git/info/refs?service=git-upload-pack --output - 2>/dev/null | grep -a "${BRANCH_REF}$$" | awk '{print $$2}')) | ||
$(eval REMOTE_E2E_BRANCH := $(shell curl ${AUTHOR_LINK}/toolchain-e2e.git/info/refs?service=git-upload-pack --output - 2>/dev/null | grep -a "refs/heads/${BRANCH_NAME}$$" | awk '{print $$2}')) | ||
@echo "branch ref of the user's fork: \"${REMOTE_E2E_BRANCH}\" - if empty then not found" | ||
# check if the branch with the same name exists, if so then merge it with master and use the merge branch, if not then use master | ||
if [[ -n "${REMOTE_E2E_BRANCH}" ]]; then \ | ||
git config --global user.email "[email protected]"; \ | ||
git config --global user.name "Devtools"; \ | ||
# retrieve the branch name \ | ||
BRANCH_NAME=`echo ${BRANCH_REF} | awk -F'/' '{print $$3}'`; \ | ||
# add the user's fork as remote repo \ | ||
git --git-dir=${E2E_REPO_PATH}/.git --work-tree=${E2E_REPO_PATH} remote add external ${AUTHOR_LINK}/toolchain-e2e.git; \ | ||
# fetch the branch \ | ||
git --git-dir=${E2E_REPO_PATH}/.git --work-tree=${E2E_REPO_PATH} fetch external ${BRANCH_REF}; \ | ||
git --git-dir=${E2E_REPO_PATH}/.git --work-tree=${E2E_REPO_PATH} fetch external ${REMOTE_E2E_BRANCH}; \ | ||
# merge the branch with master \ | ||
git --git-dir=${E2E_REPO_PATH}/.git --work-tree=${E2E_REPO_PATH} merge --allow-unrelated-histories --no-commit FETCH_HEAD; \ | ||
fi; | ||
|