From 85299c6dde6553d0ae0b0349d3f50f1731586f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D1=8C=D1=81=D0=BE=D0=BD=20?= =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 27 Dec 2018 13:12:43 +0700 Subject: [PATCH] Skip PR if wip --- assets/check | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/assets/check b/assets/check index fce7c8b..af15609 100755 --- a/assets/check +++ b/assets/check @@ -43,11 +43,13 @@ if [[ "$bitbucket_type" == "server" ]]; then curl -sS --fail -u ${username}:${password} $uri | jq -r \ '.values | map({ - id: .id | tostring, + id: .id | tostring, + title: .title | tostring, branch: .fromRef.id | tostring | (capture("refs/heads/(?.+)").branch // .), commit: .fromRef.latestCommit, updated_at: .updatedDate | tostring - }) + }) + | map(select(if .title | test("wip"; "i") then false else true end)) | map(select(.updated_at >= '$version_updated_at')) | sort_by(.updated_at)' >&3 elif [[ "$bitbucket_type" == "cloud" ]]; then @@ -61,6 +63,7 @@ elif [[ "$bitbucket_type" == "cloud" ]]; then while read -r pullrequest; do branch=$(echo "$pullrequest" | jq -r '.source.branch.name') id=$(echo "$pullrequest" | jq -r '.id') + title=$(echo "$pullrequest" | jq -r '.title') commit=$(echo "$pullrequest" | jq -r '.source.commit.hash') commit_url=$(echo "$pullrequest" | jq -r '.source.commit.links.self.href') @@ -68,7 +71,7 @@ elif [[ "$bitbucket_type" == "cloud" ]]; then # the updated_on field in the PR also changes when comment added etc date=$(curl -s --fail -u "${username}:${password}" $commit_url | jq -r '.date') - prs+="+ [{id:\"$id\", branch: \"$branch\", commit:\"$commit\", updated_at:\"$date\"}]" + prs+="+ [{id:\"$id\", title: \"$title\", branch: \"$branch\", commit:\"$commit\", updated_at:\"$date\"}]" done < <(jq -c '.[]' "${response}") if [[ "$prs" == "[]" ]]; then @@ -76,7 +79,11 @@ elif [[ "$bitbucket_type" == "cloud" ]]; then exit fi - # take the list of PRs | sort by update-date of commits | remove the date | pick latest PR, wrap as array for concourse - jq -n "[ $prs | sort_by(.updated_at) | map(del(.updated_at)) | .[-1] ]" >&3 + # take the list of PRs | filter out containing "wip" in title | sort by update-date of commits | remove the date | pick latest PR, wrap as array for concourse + jq -n "[ $prs + | map(select(if .title | test('wip'; 'i') then false else true end)) + | sort_by(.updated_at) + | map(del(.updated_at)) + | .[-1] ]" >&3 fi