Skip to content

Commit fc85082

Browse files
authored
Enhance diff check logic in develop-update (#6)
2 parents 8c335b0 + 8842be8 commit fc85082

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

.github/workflows/develop-update.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,19 @@ jobs:
3636
uses: actions/checkout@v4
3737
with:
3838
ref: main
39-
39+
4040
# Ensure diff between main and develop
4141
- name: "Check if there is a diff between main and develop"
4242
id: check_diff
4343
run: |
4444
git fetch origin develop
45-
DIFF=$(git diff origin/develop..main)
46-
if [ -z "$DIFF" ]; then
47-
echo "No differences found between main and develop."
45+
# Check if there are commits in main that aren't in develop
46+
COMMITS=$(git rev-list origin/develop..main --count)
47+
if [ "$COMMITS" -eq 0 ]; then
48+
echo "No commits found in main that aren't in develop. Develop is up to date or ahead."
4849
echo "diff=false" >> $GITHUB_OUTPUT
4950
else
50-
echo "Differences found between main and develop."
51+
echo "Found $COMMITS commit(s) in main that aren't in develop."
5152
echo "diff=true" >> $GITHUB_OUTPUT
5253
fi
5354
- name: "Check if existing PR exists"
@@ -119,7 +120,7 @@ jobs:
119120
throw error;
120121
}
121122
}
122-
123+
123124
# PR Creation
124125
- name: "Create Pull Request to update develop branch, and merge it"
125126
id: create_pr

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ The workflow intelligently handles different merge scenarios:
182182

183183
This ensures that hotfixes and other direct merges to `main` are properly reviewed before being merged back to `develop`.
184184

185-
If a merge is not detected, the main and develop branches are already in sync or an existing PR between main and develop exists, the workflow will exit without merging changes, but will create a PR if possible.
185+
If no commits are found in `main` that aren't in `develop`, or an existing PR between main and develop exists, the workflow will exit without merging changes, but will create a PR if possible.
186186

187187
#### Inputs
188188

0 commit comments

Comments
 (0)