Remove non-standard : anchors
This commit is contained in:
@@ -3,23 +3,26 @@
|
||||
# Checks if a CI build affects one or more path patterns. Each command-line
|
||||
# argument is checked in series.
|
||||
#
|
||||
# Bash regular expresses are permitted in the pattern, and the colon (':')
|
||||
# character is guaranteed to appear before and after each affected file (and thus
|
||||
# can be used as an anchor), eg:
|
||||
# .rs: -- any file or directory ending in .rs
|
||||
# .rs -- also matches foo.rs.bar
|
||||
# :snap/ -- anything under the snap/ subdirectory
|
||||
# snap/ -- also matches foo/snap/
|
||||
# Bash regular expressions are permitted in the pattern:
|
||||
# ./affects-files.sh .rs$ -- any file or directory ending in .rs
|
||||
# ./affects-files.sh .rs -- also matches foo.rs.bar
|
||||
# ./affects-files.sh ^snap/ -- anything under the snap/ subdirectory
|
||||
# ./affects-files.sh snap/ -- also matches foo/snap/
|
||||
#
|
||||
set -e
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
if ci/is-pr.sh; then
|
||||
affectedFiles="$(buildkite-agent meta-data get affected_files)"
|
||||
echo "Affected files in this PR: $affectedFiles"
|
||||
|
||||
IFS=':' read -ra files <<< "$affectedFiles"
|
||||
for pattern in "$@"; do
|
||||
if [[ ":$affectedFiles:" =~ $pattern ]]; then
|
||||
exit 0
|
||||
fi
|
||||
for file in "${files[@]}"; do
|
||||
if [[ $file =~ $pattern ]]; then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit 1
|
||||
|
Reference in New Issue
Block a user