EESSI / software-layer

Software layer of the EESSI project
https://eessi.github.io/docs/software_layer
GNU General Public License v2.0
23 stars 46 forks source link

logic to determine `from-pr` fails when `.diff` files includes extra 'from-pr' #536

Open trz42 opened 5 months ago

trz42 commented 5 months ago

Ran into the issue in https://github.com/NorESSI/software-layer/pull/301 which tests the changes implemented in https://github.com/EESSI/software-layer/pull/494 Particularly, the https://github.com/NorESSI/software-layer/pull/301 includes several comments which contain the string from-pr in addition to the option from-pr in an easystack file. A simple fix seems to be to slightly modify the search pattern to from-pr: in the second grep. See example runs below.

The original search pattern from-pr in the second grep returns the following:

[nessibot@login1 ~]$ grep ^+ /project/def-nessi/SHARED/jobs/2024.04/pr_301/9129/301.diff | grep from-pr
+    # Find lines that are added and use from-pr, make them unique, grab the
+    pr_exceptions=$(grep ^+ $2 | grep from-pr | uniq | awk '{print $3}' | xargs -i echo " || /'{}'/")
+    # We might have failed due to unmerged PRs. Try to make exceptions for --from-pr added in this PR
+    # Note that if no --from-pr's were used in this PR, $pr_exceptions will be empty and we might as
+    awk_command="awk '\!/'from-pr'/ EXCEPTIONS' $easystack"
+    msg="${msg} allowing for --from-pr's that were added in this PR..."
+    # If now we succeeded, the reason must be that we originally stripped the --from-pr's
+        from-pr: 20308

With this the full command to determine the pr_exceptions (in check_missing_installations.sh) returns:

[nessibot@login1 ~]$ grep ^+ /project/def-nessi/SHARED/jobs/2024.04/pr_301/9129/301.diff | grep from-pr  | uniq | awk '{print $3}' | xargs -i echo " || /'{}'/"
 || /'Find'/
 || /'^+'/
 || /'We'/
 || /'Note'/
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

After modifying the search pattern to from-pr: in the second grep, we get the following

[nessibot@login1 ~]$ grep ^+ /project/def-nessi/SHARED/jobs/2024.04/pr_301/9129/301.diff | grep from-pr:
+        from-pr: 20308

and the full command returns

[nessibot@login1 ~]$ grep ^+ /project/def-nessi/SHARED/jobs/2024.04/pr_301/9129/301.diff | grep from-pr: |uniq | awk '{print $3}' | xargs -i echo " || /'{}'/"
 || /'20308'/