|
514 | 514 | }, sourceElem); |
515 | 515 | } |
516 | 516 | }, |
| 517 | + { |
| 518 | + title: 'Cherry Pick this Commit', |
| 519 | + onClick: () => { |
| 520 | + if (this.commits[this.commitLookup[hash]].parentHashes.length === 1) { |
| 521 | + showConfirmationDialog('Are you sure you want to cherry pick commit <b><i>' + abbrevCommit(hash) + '</i></b>?', () => { |
| 522 | + sendMessage({ command: 'cherrypickCommit', commitHash: hash, parentIndex: 0 }); |
| 523 | + }, sourceElem); |
| 524 | + } else { |
| 525 | + let options = this.commits[this.commitLookup[hash]].parentHashes.map((hash, index) => ({ |
| 526 | + name: abbrevCommit(hash) + (typeof this.commitLookup[hash] === 'number' ? ': ' + this.commits[this.commitLookup[hash]].message : ''), |
| 527 | + value: (index + 1).toString() |
| 528 | + })); |
| 529 | + showSelectDialog('Are you sure you want to cherry pick merge commit <b><i>' + abbrevCommit(hash) + '</i></b>? Choose the parent hash on the main branch, to cherry pick the commit relative to:', '1', options, 'Yes, cherry pick commit', (parentIndex) => { |
| 530 | + sendMessage({ command: 'cherrypickCommit', commitHash: hash, parentIndex: parseInt(parentIndex) }); |
| 531 | + }, sourceElem); |
| 532 | + } |
| 533 | + } |
| 534 | + }, |
| 535 | + { |
| 536 | + title: 'Reverse this Commit', |
| 537 | + onClick: () => { |
| 538 | + if (this.commits[this.commitLookup[hash]].parentHashes.length === 1) { |
| 539 | + showConfirmationDialog('Are you sure you want to reverse commit <b><i>' + abbrevCommit(hash) + '</i></b>?', () => { |
| 540 | + sendMessage({ command: 'revertCommit', commitHash: hash, parentIndex: 0 }); |
| 541 | + }, sourceElem); |
| 542 | + } else { |
| 543 | + let options = this.commits[this.commitLookup[hash]].parentHashes.map((hash, index) => ({ |
| 544 | + name: abbrevCommit(hash) + (typeof this.commitLookup[hash] === 'number' ? ': ' + this.commits[this.commitLookup[hash]].message : ''), |
| 545 | + value: (index + 1).toString() |
| 546 | + })); |
| 547 | + showSelectDialog('Are you sure you want to reverse merge commit <b><i>' + abbrevCommit(hash) + '</i></b>? Choose the parent hash on the main branch, to reverse the commit relative to:', '1', options, 'Yes, reverse commit', (parentIndex) => { |
| 548 | + sendMessage({ command: 'revertCommit', commitHash: hash, parentIndex: parseInt(parentIndex) }); |
| 549 | + }, sourceElem); |
| 550 | + } |
| 551 | + } |
| 552 | + }, |
517 | 553 | { |
518 | 554 | title: 'Reset current branch to this Commit', |
519 | 555 | onClick: () => { |
|
570 | 606 | } |
571 | 607 | }]; |
572 | 608 | if (sourceElem.className === 'gitRef head') { |
573 | | - menu.push({ |
574 | | - title: 'Rename Branch', |
575 | | - onClick: () => { |
576 | | - showInputDialog('Enter the new name for branch <b><i>' + escapeHtml(refName) + '</i></b>:', refName, 'Rename Branch', (newName) => { |
577 | | - sendMessage({ command: 'renameBranch', oldName: refName, newName: newName }); |
578 | | - }, null); |
579 | | - } |
580 | | - }); |
581 | | - menu.push({ |
582 | | - title: 'Delete Branch', |
583 | | - onClick: () => { |
584 | | - showCheckboxDialog('Are you sure you want to delete the branch <b><i>' + escapeHtml(refName) + '</i></b>?', 'Force Delete', 'Delete Branch', (forceDelete) => { |
585 | | - sendMessage({ command: 'deleteBranch', branchName: refName, forceDelete: forceDelete }); |
586 | | - }, null); |
| 609 | + menu.push( |
| 610 | + { |
| 611 | + title: 'Rename Branch', |
| 612 | + onClick: () => { |
| 613 | + showInputDialog('Enter the new name for branch <b><i>' + escapeHtml(refName) + '</i></b>:', refName, 'Rename Branch', (newName) => { |
| 614 | + sendMessage({ command: 'renameBranch', oldName: refName, newName: newName }); |
| 615 | + }, null); |
| 616 | + } |
| 617 | + }, { |
| 618 | + title: 'Delete Branch', |
| 619 | + onClick: () => { |
| 620 | + showCheckboxDialog('Are you sure you want to delete the branch <b><i>' + escapeHtml(refName) + '</i></b>?', 'Force Delete', 'Delete Branch', (forceDelete) => { |
| 621 | + sendMessage({ command: 'deleteBranch', branchName: refName, forceDelete: forceDelete }); |
| 622 | + }, null); |
| 623 | + } |
587 | 624 | } |
588 | | - }); |
| 625 | + ); |
| 626 | + if (this.branchOptions.length > 0 && this.branchOptions[0] !== refName) { |
| 627 | + menu.push({ |
| 628 | + title: 'Merge into current branch', |
| 629 | + onClick: () => { |
| 630 | + showConfirmationDialog('Are you sure you want to merge branch <b><i>' + escapeHtml(refName) + '</i></b> into the current branch?', () => { |
| 631 | + sendMessage({ command: 'mergeBranch', branchName: refName }); |
| 632 | + }, null); |
| 633 | + } |
| 634 | + }); |
| 635 | + } |
589 | 636 | } |
590 | 637 | } |
591 | 638 | showContextMenu(<MouseEvent>e, menu, sourceElem); |
|
698 | 745 | case 'checkoutBranch': |
699 | 746 | refreshGraphOrDisplayError(msg.status, 'Unable to Checkout Branch'); |
700 | 747 | break; |
| 748 | + case 'cherrypickCommit': |
| 749 | + refreshGraphOrDisplayError(msg.status, 'Unable to Cherry Pick Commit'); |
| 750 | + break; |
701 | 751 | case 'commitDetails': |
702 | 752 | if (msg.commitDetails === null) { |
703 | 753 | gitGraph.hideCommitDetails(); |
|
724 | 774 | case 'loadCommits': |
725 | 775 | gitGraph.loadCommits(msg.commits, msg.moreCommitsAvailable); |
726 | 776 | break; |
| 777 | + case 'mergeBranch': |
| 778 | + refreshGraphOrDisplayError(msg.status, 'Unable to Merge Branch'); |
| 779 | + break; |
727 | 780 | case 'renameBranch': |
728 | 781 | refreshGraphOrDisplayError(msg.status, 'Unable to Rename Branch'); |
729 | 782 | break; |
730 | 783 | case 'resetToCommit': |
731 | 784 | refreshGraphOrDisplayError(msg.status, 'Unable to Reset to Commit'); |
732 | 785 | break; |
| 786 | + case 'revertCommit': |
| 787 | + refreshGraphOrDisplayError(msg.status, 'Unable to Reverse Commit'); |
| 788 | + break; |
733 | 789 | case 'viewDiff': |
734 | 790 | if (msg.success === false) showErrorDialog('Unable to view diff of file', null, null); |
735 | 791 | break; |
|
0 commit comments