Skip to content

Commit

Permalink
Don't check if target branch is master
Browse files Browse the repository at this point in the history
  • Loading branch information
MDrakos committed Nov 6, 2024
1 parent 7ff9681 commit 85a8031
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions activestate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,35 +389,33 @@ scripts:
standalone: true
description: "Checks if the code is formatted correctly"
value: |
set -e
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
echo "Detected shallow clone, fetching complete history..."
git fetch --unshallow origin master
TARGET_BRANCH=$GITHUB_BASE_REF
if [ "$GITHUB_BASE_REF" == "" ]; then
TARGET_BRANCH="master"
fi
git fetch origin master:refs/remotes/origin/master
MERGE_BASE=$(git merge-base HEAD origin/master)
CHANGED=$(git diff --name-only $MERGE_BASE...HEAD | grep -v testdata | grep -v vendor) || true
if [ -z "$CHANGED" ]; then
echo "No relevant changed files found"
if [ "$TARGET_BRANCH" == "master" ]; then
echo "Target branch is master, not checking for newlines"
exit 0
fi
echo "Changed files: $CHANGED"
CHANGED=$(git diff --name-only origin/$TARGET_BRANCH | grep -v testdata | grep -v vendor)
NO_NEWLINE=0
for FILE in $CHANGED; do
if [ ! -f "$FILE" ]; then
continue
fi
if file "$FILE" | grep -q -E 'text|ASCII'; then
if [ $(tail -c 1 "$FILE" | wc -l) -eq 0 ]; then
echo "Missing newline at end of file: $FILE"
NO_NEWLINE=1
fi
fi
done
if [ "$NO_NEWLINE" -ne 0 ]; then
echo "Error: Some text files are missing a newline at the end."
exit 1
else
echo "Success: All modified text files end with a newline."
fi
- name: grab-mergecommits
language: bash
standalone: true
Expand Down

0 comments on commit 85a8031

Please sign in to comment.