From 742794772066ee57caedc4767ab0051fd0abbc78 Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Mon, 30 Apr 2018 15:02:11 -0400 Subject: [PATCH] Let checkTests work for PRs Signed-off-by: Johnny Bieren --- src/org/centos/pipeline/PipelineUtils.groovy | 18 ++++++++++++++---- vars/pipelineUtils.groovy | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/org/centos/pipeline/PipelineUtils.groovy b/src/org/centos/pipeline/PipelineUtils.groovy index 7fd166d2..ae274e23 100644 --- a/src/org/centos/pipeline/PipelineUtils.groovy +++ b/src/org/centos/pipeline/PipelineUtils.groovy @@ -1156,17 +1156,27 @@ def watchForMessages(String msg_provider, String message) { /** * Test if $tag tests exist for $mypackage on $mybranch in fedora dist-git - * For mybranch, use fXX or master + * For mybranch, use fXX or master, or PR number (digits only) * @param mypackage - * @param mybranch + * @param mybranch - Fedora branch or PR number * @param tag * @return */ def checkTests(String mypackage, String mybranch, String tag) { echo "Currently checking if package tests exist" sh "rm -rf ${mypackage}" - return sh (returnStatus: true, script: """ - git clone -b ${mybranch} --single-branch https://src.fedoraproject.org/rpms/${mypackage}/ && grep -r '\\- '${tag}'\$' ${mypackage}/tests""") == 0 + if (mybranch.isNumber()) { + sh "git clone https://src.fedoraproject.org/rpms/${mypackage}" + dir("${mypackage}") { + sh "git fetch -fu origin refs/pull/${mybranch}/head:pr" + sh "git checkout pr" + return sh (returnStatus: true, script: """ + grep -r '\\- '${tag}'\$' tests""") == 0 + } + } else { + return sh (returnStatus: true, script: """ + git clone -b ${mybranch} --single-branch https://src.fedoraproject.org/rpms/${mypackage}/ && grep -r '\\- '${tag}'\$' ${mypackage}/tests""") == 0 + } } /** diff --git a/vars/pipelineUtils.groovy b/vars/pipelineUtils.groovy index 0a9f90b0..847518d2 100644 --- a/vars/pipelineUtils.groovy +++ b/vars/pipelineUtils.groovy @@ -303,9 +303,9 @@ class pipelineUtils implements Serializable { /** * Test if $tag tests exist for $mypackage on $mybranch in fedora dist-git - * For mybranch, use fXX or master + * For mybranch, use fXX or master or PR number (digits only) * @param mypackage - * @param mybranch + * @param mybranch - Fedora branch or PR number * @param tag * @return */