Skip to content

Commit 715d415

Browse files
committed
chore: update version to 6.2 and enhance cleanup of PR selection containers
1 parent 11e31ca commit 715d415

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

MergeDependabotPRs.user.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Auto-Merge Dependabot PRs
33
// @namespace typpi.online
4-
// @version 6.1
4+
// @version 6.2
55
// @description Merges Dependabot PRs in any of your repositories - pulls the PRs into a table and lets you select which ones to merge.
66
// @author Nick2bad4u
77
// @match https://github.com/notifications
@@ -344,7 +344,10 @@
344344
index++;
345345
setTimeout(processNextPR, delay);
346346
} else {
347-
setTimeout(() => statusContainer.remove(), 10000);
347+
setTimeout(() => {
348+
statusContainer.remove();
349+
removeAllPRSelectionContainers();
350+
}, 10000);
348351
}
349352
}
350353

@@ -356,6 +359,7 @@
356359
messageElement.innerHTML = `Failed to process PRs for repo ${repo}: ${error.message || 'Unknown error'}<br>`;
357360
statusContainer.appendChild(messageElement);
358361
setTimeout(() => messageElement.remove(), 7000);
362+
removeAllPRSelectionContainers();
359363
}
360364
}
361365

@@ -583,6 +587,7 @@
583587
container.remove();
584588
const status = document.getElementById('merge-status');
585589
if (status) status.remove();
590+
removeAllPRSelectionContainers(); // Ensure all are removed
586591
};
587592
container.appendChild(closeBtn);
588593

@@ -639,16 +644,30 @@
639644

640645
// Merge PRs grouped by repository
641646
for (const [repo, prs] of Object.entries(groupedPRs)) {
642-
await mergeDependabotPRs(prs, username, repo, token);
647+
try {
648+
await mergeDependabotPRs(prs, username, repo, token);
649+
} catch (error) {
650+
console.error(`Error merging PRs for repo ${repo}:`, error);
651+
const status = document.getElementById('merge-status');
652+
if (status) status.remove();
653+
container.remove();
654+
removeAllPRSelectionContainers();
655+
alert(`Failed to merge PRs for repo ${repo}. Please check the console for details.`);
656+
return;
657+
}
643658
setTimeout(() => {
644659
const status = document.getElementById('merge-status');
645660
if (status) status.remove();
646661
container.remove();
662+
removeAllPRSelectionContainers();
647663
}, 11000); // Wait for status to finish
648664
}
649665
} else {
650666
container.innerHTML = 'No PRs selected for merging.';
651-
setTimeout(() => container.remove(), 2000);
667+
setTimeout(() => {
668+
container.remove();
669+
removeAllPRSelectionContainers();
670+
}, 2000);
652671
}
653672
});
654673

@@ -658,6 +677,8 @@
658677
} catch (error) {
659678
console.error('Failed to display PR selection:', error);
660679
removeAllPRSelectionContainers(); // Clean up on error
680+
const status = document.getElementById('merge-status');
681+
if (status) status.remove();
661682
alert('An error occurred while displaying the PR selection. Please check the console for details.');
662683
}
663684
}

0 commit comments

Comments
 (0)