mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-18 10:42:14 -05:00
d929d049cb
Some checks failed
Publish Images / Build and Test (push) Has been cancelled
Build and Test / Set build metadata (push) Has been cancelled
Build and Test / Build test suite matrix (push) Has been cancelled
Build and Test / preview-release-notes (push) Has been cancelled
Lint commit / commitlint (push) Has been cancelled
Publish Images / Release (push) Has been cancelled
Build and Test / Build and Test (push) Has been cancelled
Build and Test / Test the Super-linter GitHub Action (push) Has been cancelled
Build and Test / Run test cases (push) Has been cancelled
Build and Test / Check if all the tests passed (push) Has been cancelled
The https://github.com/super-linter/super-linter/pull/6113 introduced new Git merge conflicts linter check, that is error prone in some conditions (see screenshot). This PR adjusts this check to be more precise and exact in a way that all three markers should be found to identify check as failed. Additionally improve Git merge conflict markers matchers. Co-authored-by: Marco Ferrari <ferrari.marco@gmail.com>
31 lines
629 B
Bash
Executable file
31 lines
629 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
GIT_MERGE_CONFLICT_START='^<{7} .+$'
|
|
GIT_MERGE_CONFLICT_MIDST='^={7}$'
|
|
GIT_MERGE_CONFLICT_END='^>{7} .+$'
|
|
|
|
if [[ "$*" == "--version" ]]; then
|
|
echo "1.0.0"
|
|
exit 0
|
|
fi
|
|
|
|
declare -i errors=0
|
|
|
|
for file in "$@"; do
|
|
if grep -q -E "${GIT_MERGE_CONFLICT_START}" "$file" &&
|
|
grep -q -E "${GIT_MERGE_CONFLICT_MIDST}" "$file" &&
|
|
grep -q -E "${GIT_MERGE_CONFLICT_END}" "$file"; then
|
|
echo "Found Git merge conflict markers: \"$file\""
|
|
errors=$((errors + 1))
|
|
fi
|
|
done
|
|
|
|
if [[ $errors -gt 0 ]]; then
|
|
exit 1
|
|
else
|
|
echo "No merge conflicts found in $*"
|
|
fi
|