Skip to content

Commit ff9a45b

Browse files
committed
Make pr_diff file available
1 parent fc3829e commit ff9a45b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

EESSI-install-software.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ fi
242242
# order is important: these are needed to install a full CUDA SDK in host_injections
243243
# for now, this just reinstalls all scripts. Note the most elegant, but works
244244

245+
# the install_scripts.sh script relies on knowing the location of the PR diff
246+
# assume there's only one diff file that corresponds to the PR patch file
247+
pr_diff=$(ls [0-9]*.diff | head -1)
248+
export PR_DIFF="$PWD/$pr_diff"
249+
245250
# Only run install_scripts.sh if not in dev.eessi.io for security
246251
if [[ -z ${EESSI_DEV_PROJECT} ]]; then
247252
${TOPDIR}/install_scripts.sh --prefix ${EESSI_PREFIX}
@@ -341,10 +346,6 @@ else
341346
echo_green ">> MODULEPATH set up: ${MODULEPATH}"
342347
fi
343348

344-
# assume there's only one diff file that corresponds to the PR patch file
345-
pr_diff=$(ls [0-9]*.diff | head -1)
346-
347-
348349
# use PR patch file to determine in which easystack files stuff was added
349350
changed_easystacks=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep 'easystacks/.*yml$' | egrep -v 'known-issues|missing')
350351
if [ -z "${changed_easystacks}" ]; then

install_scripts.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ file_changed_in_pr() {
1515
# Make sure file exists
1616
[[ -f "$full_path" ]] || return 1
1717

18-
# Check if the file is in a Git repo
18+
# Check if the file is in a Git repo (it should be)
1919
local repo_root
2020
repo_root=$(git -C "$(dirname "$full_path")" rev-parse --show-toplevel 2>/dev/null)
2121
if [[ -z "$repo_root" ]]; then
@@ -26,10 +26,14 @@ file_changed_in_pr() {
2626
local rel_path
2727
rel_path=$(realpath --relative-to="$repo_root" "$full_path")
2828

29-
# Check if the file changed in the diff range
29+
# Check if the file changed in the PR diff file that we have
3030
(
3131
cd "$repo_root" || return 2
32-
git diff --name-only "$base_branch"...HEAD | grep -q "^$rel_path$"
32+
if [ -f "$PR_DIFF" ]; then # PR_DIFF should be set by the calling script
33+
grep -q "b/$rel_path" "$pr_diff" # Add b/ to match diff patterns
34+
else
35+
return 3
36+
fi
3337
) && return 0 || return 1
3438
}
3539

@@ -51,8 +55,9 @@ compare_and_copy() {
5155
echo "File $source_file copied to $destination_file"
5256
else
5357
case $? in
54-
1) echo "❌ File has NOT changed" ;;
55-
2) echo "🚫 Not in a Git repo" ;;
58+
1) echo "❌ File has NOT changed in PR" ;;
59+
2) echo "🚫 Not in Git repository" ;;
60+
3) echo "🚫 No PR diff file found" ;;
5661
*) echo "⚠️ Unknown error" ;;
5762
esac
5863
fi

0 commit comments

Comments
 (0)