Skip to content
Snippets Groups Projects
Commit 334e9333 authored by cheme's avatar cheme Committed by GitHub
Browse files

Companion PR ci sed issue. (#5508)



* ci: fix echo sed failure

Co-authored-by: default avatargabriel <gabriel@parity.io>
parent c9f3d16f
Branches
No related merge requests found
...@@ -40,7 +40,6 @@ substrate's branch. if it can't find anything, it will uses master instead ...@@ -40,7 +40,6 @@ substrate's branch. if it can't find anything, it will uses master instead
EOT EOT
SUBSTRATE_PATH=$(pwd) SUBSTRATE_PATH=$(pwd)
# Clone the current Polkadot master branch into ./polkadot. # Clone the current Polkadot master branch into ./polkadot.
...@@ -54,15 +53,18 @@ if expr match "${CI_COMMIT_REF_NAME}" '^[0-9]\+$' >/dev/null ...@@ -54,15 +53,18 @@ if expr match "${CI_COMMIT_REF_NAME}" '^[0-9]\+$' >/dev/null
then then
boldprint "this is pull request no ${CI_COMMIT_REF_NAME}" boldprint "this is pull request no ${CI_COMMIT_REF_NAME}"
pr_data_file="$(mktemp)"
# get the last reference to a pr in polkadot # get the last reference to a pr in polkadot
pr_data="$(curl -sSL -H "${github_header}" -s ${github_api_substrate_pull_url}/${CI_COMMIT_REF_NAME})" curl -sSL -H "${github_header}" -o "${pr_data_file}" \
pr_ref="$(echo $pr_data | grep -Po '"ref"\s*:\s*"\K(?!master)[^"]*')" "${github_api_substrate_pull_url}/${CI_COMMIT_REF_NAME}"
pr_body="$(echo $pr_data | sed -n -r 's/^[[:space:]]+"body": (".*")[^"]+$/\1/p')"
pr_body="$(sed -n -r 's/^[[:space:]]+"body": (".*")[^"]+$/\1/p' "${pr_data_file}")"
pr_companion="$(echo "${pr_body}" | sed -n -r \ pr_companion="$(echo "${pr_body}" | sed -n -r \
-e 's;^.*polkadot companion: paritytech/polkadot#([0-9]+).*$;\1;p' \ -e 's;^.*polkadot companion: paritytech/polkadot#([0-9]+).*$;\1;p' \
-e 's;^.*polkadot companion: https://github.com/paritytech/polkadot/pull/([0-9]+).*$;\1;p' \ -e 's;^.*polkadot companion: https://github.com/paritytech/polkadot/pull/([0-9]+).*$;\1;p' \
| tail -n 1)" | tail -n 1)"
if [ -z "${pr_companion}" ] if [ -z "${pr_companion}" ]
then then
pr_companion="$(echo "${pr_body}" | sed -n -r \ pr_companion="$(echo "${pr_body}" | sed -n -r \
...@@ -76,7 +78,8 @@ then ...@@ -76,7 +78,8 @@ then
git fetch --depth 1 origin refs/pull/${pr_companion}/head:pr/${pr_companion} git fetch --depth 1 origin refs/pull/${pr_companion}/head:pr/${pr_companion}
git checkout pr/${pr_companion} git checkout pr/${pr_companion}
else else
if git fetch --depth 1 origin "$pr_ref":branch/"$pr_ref" pr_ref="$(grep -Po '"ref"\s*:\s*"\K(?!master)[^"]*' "${pr_data_file}")"
if git fetch --depth 1 origin "$pr_ref":branch/"$pr_ref" 2>/dev/null
then then
boldprint "companion branch detected: $pr_ref" boldprint "companion branch detected: $pr_ref"
git checkout branch/"$pr_ref" git checkout branch/"$pr_ref"
...@@ -84,6 +87,7 @@ then ...@@ -84,6 +87,7 @@ then
boldprint "no companion branch found - building polkadot:master" boldprint "no companion branch found - building polkadot:master"
fi fi
fi fi
rm -f "${pr_data_file}"
else else
boldprint "this is not a pull request - building polkadot:master" boldprint "this is not a pull request - building polkadot:master"
fi fi
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment