@@ -24,46 +24,50 @@ jobs:
24
24
- name : Check if changes were trivial
25
25
id : check_trivial_changes
26
26
run : |
27
- git fetch origin ${{ github.base_ref }} --unshallow
28
- base_ref=origin/${{ github.base_ref }}
29
- head_ref=HEAD
30
- changed_files=$(git diff-tree --name-status -r "$base_ref".."$head_ref" -- | cut -f2 -d$'\t')
31
- # Flag to check whether we do the rest of checks
32
- exception=true
33
-
34
- for file in $changed_files; do
35
- # If changes were to a markdown file we don't mind
36
- if [[ $file == *.md ]]; then
37
- echo "$file: is markdown, so it doesn't matter (trivial change)"
38
- continue
39
- fi
40
-
41
- # If changes were to a .cabal file, we ensure only the version changed
42
- if [[ $file == *.cabal ]]; then
43
- # If file doesn't exist it means it was moved or removed
44
- if [ ! -f "$file" ]; then
45
- echo "$file: was moved or removed and is a cabal file (non-trivial change)"
46
- exception=false
47
- break
27
+ if [ -z "${{ github.base_ref }}" ]; then
28
+ exception=false
29
+ else
30
+ git fetch origin ${{ github.base_ref }} --unshallow
31
+ base_ref=origin/${{ github.base_ref }}
32
+ head_ref=HEAD
33
+ changed_files=$(git diff-tree --name-status -r "$base_ref".."$head_ref" -- | cut -f2 -d$'\t')
34
+ # Flag to check whether we do the rest of checks
35
+ exception=true
36
+
37
+ for file in $changed_files; do
38
+ # If changes were to a markdown file we don't mind
39
+ if [[ $file == *.md ]]; then
40
+ echo "$file : is markdown, so it doesn't matter (trivial change)"
41
+ continue
48
42
fi
49
-
50
- # We ensure the only change was to the version field
51
- diff_version=$(git diff "$base_ref".."$head_ref" -- "$file" | perl -ne 'print if /^-(?!version:)/' | wc -l)
52
- diff_no_version=$(git diff "$base_ref".."$head_ref" -- "$file" | perl -ne 'print if /^\+(?!version:)/' | wc -l)
53
-
54
- if [ "$diff_version" -gt 1 ] || [ "$diff_no_version" -gt 1 ]; then
55
- echo "$file: was modified beyond the version tag (non-trivial change)"
43
+
44
+ # If changes were to a .cabal file, we ensure only the version changed
45
+ if [[ $file == *.cabal ]]; then
46
+ # If file doesn't exist it means it was moved or removed
47
+ if [ ! -f "$file" ]; then
48
+ echo "$file : was moved or removed and is a cabal file (non-trivial change)"
49
+ exception=false
50
+ break
51
+ fi
52
+
53
+ # We ensure the only change was to the version field
54
+ diff_version=$(git diff "$base_ref".."$head_ref" -- "$file" | perl -ne 'print if /^-(?!version:)/' | wc -l)
55
+ diff_no_version=$(git diff "$base_ref".."$head_ref" -- "$file" | perl -ne 'print if /^\+(?!version:)/' | wc -l)
56
+
57
+ if [ "$diff_version" -gt 1 ] || [ "$diff_no_version" -gt 1 ]; then
58
+ echo "$file : was modified beyond the version tag (non-trivial change)"
59
+ exception=false
60
+ break
61
+ fi
62
+ echo "In $file, at most the version field was modified"
63
+ else
64
+ # If other types of files were changed, do not skip the checks
65
+ echo "$file : was changed and is not a markdown nor a cabal file (non-trivial change)"
56
66
exception=false
57
67
break
58
68
fi
59
- echo "In $file, at most the version field was modified"
60
- else
61
- # If other types of files were changed, do not skip the checks
62
- echo "$file: was changed and is not a markdown nor a cabal file (non-trivial change)"
63
- exception=false
64
- break
65
- fi
66
- done
69
+ done
70
+ fi
67
71
68
72
if $exception; then
69
73
echo "CHECK_HLS_WORKS=0" >> "$GITHUB_OUTPUT"
0 commit comments