Skip to content

Commit 6baea31

Browse files
Copilotcarstenartur
andcommitted
Final improvements: better variable naming, commit message, and robust file checking
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
1 parent cc76496 commit 6baea31

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

.github/workflows/sync-upstream.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838
# Create temporary directory for fork-specific files
3939
mkdir -p /tmp/fork-specific
4040
41-
# Get list of all files in fork (filtering for fork-specific happens in the loop)
42-
ALL_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
41+
# Get list of all files in current branch
42+
FILES_TO_CHECK=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
4343
44-
# For each file in fork, check if it exists in upstream
45-
for file in $ALL_FILES; do
44+
# For each file in fork, check if it exists in upstream (files that don't = fork-specific)
45+
for file in $FILES_TO_CHECK; do
4646
if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
4747
echo "Fork-specific file: $file"
4848
# Create directory structure and copy file
@@ -52,7 +52,7 @@ jobs:
5252
done
5353
5454
# Check if any fork-specific files were found
55-
if [ -d "/tmp/fork-specific" ] && [ -n "$(find /tmp/fork-specific -type f)" ]; then
55+
if [ -d "/tmp/fork-specific" ] && find /tmp/fork-specific -type f -print -quit | grep -q .; then
5656
echo "has_fork_files=true" >> $GITHUB_OUTPUT
5757
echo "Found fork-specific files:"
5858
find /tmp/fork-specific -type f
@@ -95,9 +95,7 @@ jobs:
9595
9696
sync-manual:
9797
name: Sync Fork (Manual)
98-
if: |
99-
github.event_name == 'issue_comment' &&
100-
contains(github.event.comment.body, '/sync-upstream')
98+
if: contains(github.event.comment.body, '/sync-upstream')
10199
runs-on: ubuntu-latest
102100
permissions:
103101
contents: write
@@ -175,11 +173,11 @@ jobs:
175173
# Create temporary directory for fork-specific files
176174
mkdir -p /tmp/fork-specific
177175
178-
# Get list of all files in fork (filtering for fork-specific happens in the loop)
179-
ALL_FILES=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
176+
# Get list of all files in current branch
177+
FILES_TO_CHECK=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
180178
181-
# For each file in fork, check if it exists in upstream
182-
for file in $ALL_FILES; do
179+
# For each file in fork, check if it exists in upstream (files that don't = fork-specific)
180+
for file in $FILES_TO_CHECK; do
183181
if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
184182
echo "Fork-specific file: $file"
185183
# Create directory structure and copy file
@@ -189,7 +187,7 @@ jobs:
189187
done
190188
191189
# Check if any fork-specific files were found
192-
if [ -d "/tmp/fork-specific" ] && [ -n "$(find /tmp/fork-specific -type f)" ]; then
190+
if [ -d "/tmp/fork-specific" ] && find /tmp/fork-specific -type f -print -quit | grep -q .; then
193191
echo "has_fork_files=true" >> $GITHUB_OUTPUT
194192
echo "Found fork-specific files:"
195193
find /tmp/fork-specific -type f
@@ -221,7 +219,7 @@ jobs:
221219
run: |
222220
# Check if there are changes to commit
223221
if ! git diff --cached --quiet; then
224-
git commit -m "Fork-specific CI and workflow configurations"
222+
git commit -m "Fork-specific customizations"
225223
echo "✅ Fork-specific changes committed"
226224
else
227225
echo "ℹ️ No fork-specific changes to commit"

0 commit comments

Comments
 (0)