Skip to content

Commit 7ca8ff7

Browse files
authored
Simplify space checker (#472)
1 parent 870071f commit 7ca8ff7

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

.github/workflows/space-checker.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,17 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout Code
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0 # needed to get the full history
17-
- name: Fetch upstream
18-
run: |
19-
# Fetch the main upstream branch to find the common ancestor
20-
git config --global user.name "Nemo" # required on some servers
21-
git remote add upstream https://github.com/AliceO2Group/Run3Analysisvalidation.git || exit 1
22-
git fetch upstream ${{ env.MAIN_BRANCH }} || exit 1
2317
- name: Find bad spacing
2418
run: |
2519
# Find tabs and trailing whitespaces in modified text files and show where they are
2620
status_tab=0
2721
status_trail=0
28-
# Get the common ancestor of the current branch and the main upstream branch
29-
BASE_COMMIT=$(git merge-base HEAD upstream/${{ env.MAIN_BRANCH }})
30-
echo "Diffing against: $BASE_COMMIT"
3122
# loop over changed files
32-
for f in $(git diff --diff-filter d --name-only "$BASE_COMMIT"); do
23+
# Diff against the common ancestor of the source branch and the main branch.
24+
for f in $(git diff --diff-filter d --name-only origin/${{ env.MAIN_BRANCH }}...); do
3325
# ignore binary files
3426
file -bi "$f" | grep -q "charset=binary" && continue
3527
echo "Scanning file: $f"
@@ -54,7 +46,7 @@ jobs:
5446
# shellcheck disable=2028
5547
echo "::warning::Fix the errors in your editor (or with a command)
5648
Command tips:
57-
- Get list of files you changed: git diff --diff-filter d --name-only \$(git merge-base HEAD upstream/${{ env.MAIN_BRANCH }})
49+
- Get list of files you changed: git diff --diff-filter d --name-only ${{ env.MAIN_BRANCH }}...
5850
- Replace each tab with two spaces: sed -i 's/\\t/ /g' <files>
5951
- Remove trailing whitespaces: sed -i 's/[[:space:]]*$//' <files>"
6052
echo "::warning::To avoid these errors, configure your editor to:

0 commit comments

Comments
 (0)