post_pw: Correct the patch ID detection.

Message ID 20240124133804.73253-1-aconole@redhat.com (mailing list archive)
State New
Headers
Series post_pw: Correct the patch ID detection. |

Commit Message

Aaron Conole Jan. 24, 2024, 1:38 p.m. UTC
  The patch ID detection regex can match on multiple instances of the
reported patch url.  That will cause us to send a bad API request
into the patchwork server.  Correct this by only trusting the first
value to be sent.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 post_pw.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michael Santana Jan. 24, 2024, 2:39 p.m. UTC | #1
On Wed, Jan 24, 2024 at 8:38 AM Aaron Conole <aconole@redhat.com> wrote:
>
> The patch ID detection regex can match on multiple instances of the
> reported patch url.  That will cause us to send a bad API request
> into the patchwork server.  Correct this by only trusting the first
> value to be sent.
>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Michael Santana <msantana@redhat.com>
> ---
>  post_pw.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/post_pw.sh b/post_pw.sh
> index a8111ff..f11c444 100755
> --- a/post_pw.sh
> +++ b/post_pw.sh
> @@ -63,7 +63,7 @@ send_post() {
>      context="$(echo "$report" | sed -n 's/.*Test-Label: //p' | tr ' ' '_' | tr ':' '-')"
>      state="$(echo "$report" | sed -n 's/.*Test-Status: //p' | xargs)"
>      description="$(echo "$report" | sed -ne 's/^_\(.*\)_$/\1/p')"
> -    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@')"
> +    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@' | head -n 1)"
>      target_url="$link"
>
>      api_url="${pw_instance}/api/patches/${patch_id}/checks/"
> --
> 2.41.0
>
  
Aaron Conole Jan. 24, 2024, 3:55 p.m. UTC | #2
Michael Santana <msantana@redhat.com> writes:

> On Wed, Jan 24, 2024 at 8:38 AM Aaron Conole <aconole@redhat.com> wrote:
>>
>> The patch ID detection regex can match on multiple instances of the
>> reported patch url.  That will cause us to send a bad API request
>> into the patchwork server.  Correct this by only trusting the first
>> value to be sent.
>>
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
> Acked-by: Michael Santana <msantana@redhat.com>

Thanks - applied.

>> ---
>>  post_pw.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/post_pw.sh b/post_pw.sh
>> index a8111ff..f11c444 100755
>> --- a/post_pw.sh
>> +++ b/post_pw.sh
>> @@ -63,7 +63,7 @@ send_post() {
>>      context="$(echo "$report" | sed -n 's/.*Test-Label: //p' | tr ' ' '_' | tr ':' '-')"
>>      state="$(echo "$report" | sed -n 's/.*Test-Status: //p' | xargs)"
>>      description="$(echo "$report" | sed -ne 's/^_\(.*\)_$/\1/p')"
>> -    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@')"
>> +    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@' | head -n 1)"
>>      target_url="$link"
>>
>>      api_url="${pw_instance}/api/patches/${patch_id}/checks/"
>> --
>> 2.41.0
>>
  

Patch

diff --git a/post_pw.sh b/post_pw.sh
index a8111ff..f11c444 100755
--- a/post_pw.sh
+++ b/post_pw.sh
@@ -63,7 +63,7 @@  send_post() {
     context="$(echo "$report" | sed -n 's/.*Test-Label: //p' | tr ' ' '_' | tr ':' '-')"
     state="$(echo "$report" | sed -n 's/.*Test-Status: //p' | xargs)"
     description="$(echo "$report" | sed -ne 's/^_\(.*\)_$/\1/p')"
-    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@')"
+    patch_id="$(echo "$report" | sed -ne 's@.*href.*/patch[es]*/\(.*\)/\?".*@\1@ip' | sed 's@/@@' | head -n 1)"
     target_url="$link"
 
     api_url="${pw_instance}/api/patches/${patch_id}/checks/"