|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Auto-Merge Dependabot PRs |
3 | 3 | // @namespace typpi.online |
4 | | -// @version 6.1 |
| 4 | +// @version 6.2 |
5 | 5 | // @description Merges Dependabot PRs in any of your repositories - pulls the PRs into a table and lets you select which ones to merge. |
6 | 6 | // @author Nick2bad4u |
7 | 7 | // @match https://github.com/notifications |
|
344 | 344 | index++; |
345 | 345 | setTimeout(processNextPR, delay); |
346 | 346 | } else { |
347 | | - setTimeout(() => statusContainer.remove(), 10000); |
| 347 | + setTimeout(() => { |
| 348 | + statusContainer.remove(); |
| 349 | + removeAllPRSelectionContainers(); |
| 350 | + }, 10000); |
348 | 351 | } |
349 | 352 | } |
350 | 353 |
|
|
356 | 359 | messageElement.innerHTML = `Failed to process PRs for repo ${repo}: ${error.message || 'Unknown error'}<br>`; |
357 | 360 | statusContainer.appendChild(messageElement); |
358 | 361 | setTimeout(() => messageElement.remove(), 7000); |
| 362 | + removeAllPRSelectionContainers(); |
359 | 363 | } |
360 | 364 | } |
361 | 365 |
|
|
583 | 587 | container.remove(); |
584 | 588 | const status = document.getElementById('merge-status'); |
585 | 589 | if (status) status.remove(); |
| 590 | + removeAllPRSelectionContainers(); // Ensure all are removed |
586 | 591 | }; |
587 | 592 | container.appendChild(closeBtn); |
588 | 593 |
|
|
639 | 644 |
|
640 | 645 | // Merge PRs grouped by repository |
641 | 646 | 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 | + } |
643 | 658 | setTimeout(() => { |
644 | 659 | const status = document.getElementById('merge-status'); |
645 | 660 | if (status) status.remove(); |
646 | 661 | container.remove(); |
| 662 | + removeAllPRSelectionContainers(); |
647 | 663 | }, 11000); // Wait for status to finish |
648 | 664 | } |
649 | 665 | } else { |
650 | 666 | container.innerHTML = 'No PRs selected for merging.'; |
651 | | - setTimeout(() => container.remove(), 2000); |
| 667 | + setTimeout(() => { |
| 668 | + container.remove(); |
| 669 | + removeAllPRSelectionContainers(); |
| 670 | + }, 2000); |
652 | 671 | } |
653 | 672 | }); |
654 | 673 |
|
|
658 | 677 | } catch (error) { |
659 | 678 | console.error('Failed to display PR selection:', error); |
660 | 679 | removeAllPRSelectionContainers(); // Clean up on error |
| 680 | + const status = document.getElementById('merge-status'); |
| 681 | + if (status) status.remove(); |
661 | 682 | alert('An error occurred while displaying the PR selection. Please check the console for details.'); |
662 | 683 | } |
663 | 684 | } |
|
0 commit comments