Skip to content

Commit 8d4c5a9

Browse files
Merge pull request #11 from Harsh-Microsoft/grp-depbot-security-pr
fix: Enhance merge conflict resolution in Dependabot PR grouping work…
2 parents 91b9112 + 602477b commit 8d4c5a9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.github/workflows/group-dependabot-security-updates.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
for file in "${grouped_files[@]}"; do
151151
group_name=$(basename "$file" .txt)
152152
safe_group_name=$(echo "$group_name" | tr -c '[:alnum:]_-' '-')
153-
branch_name="security/grouped-${safe_group_name}-updates"
153+
branch_name="security/grouped-${safe_group_name}updates"
154154
155155
echo "Processing group: $group_name (branch: $branch_name)"
156156
@@ -170,10 +170,10 @@ jobs:
170170
echo "Merging PR #$number ($ref) into $branch_name"
171171
git fetch origin "$ref"
172172
173-
if ! git merge FETCH_HEAD --no-edit -m "Merge PR #$number: $(echo "${pr_metadata_map["$number"]}" | cut -d'|' -f1)"; then
173+
if ! git merge FETCH_HEAD --no-edit --allow-unrelated-histories -m "Merge PR #$number: $(echo "${pr_metadata_map["$number"]}" | cut -d'|' -f1)"; then
174174
echo "Conflict found when merging PR #$number ($ref). Attempting to resolve."
175175
conflict_files=($(git diff --name-only --diff-filter=U))
176-
176+
177177
if [ ${#conflict_files[@]} -gt 0 ]; then
178178
echo "Resolving conflicts in files: ${conflict_files[*]}"
179179
for conflict_file in "${conflict_files[@]}"; do
@@ -186,13 +186,19 @@ jobs:
186186
echo "Successfully resolved conflicts and committed merge for PR #$number"
187187
else
188188
echo "Failed to commit merge resolution for PR #$number. Aborting merge."
189-
git merge --abort
189+
# Check if merge is in progress before aborting
190+
if [ -f ".git/MERGE_HEAD" ]; then
191+
git merge --abort
192+
fi
190193
merge_success=false
191194
continue
192195
fi
193196
else
194-
echo "No conflicting files found. Aborting merge for PR #$number."
195-
git merge --abort
197+
echo "No conflicting files found but merge failed. Aborting merge for PR #$number."
198+
# Check if merge is in progress before aborting
199+
if [ -f ".git/MERGE_HEAD" ]; then
200+
git merge --abort
201+
fi
196202
merge_success=false
197203
continue
198204
fi

0 commit comments

Comments
 (0)