MCPcopy Create free account
hub / github.com/SpartanJ/eepp / openBranchMenu

Method openBranchMenu

src/tools/ecode/plugins/git/gitplugin.cpp:1774–1839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1772}
1773
1774void GitPlugin::openBranchMenu( const Git::Branch& branch ) {
1775 UIPopUpMenu* menu = UIPopUpMenu::New();
1776 menu->setId( "git_branch_menu" );
1777
1778 if ( branch.type != Git::RefType::Stash ) {
1779 menuAdd( menu, "git-fetch", i18n( "git_fetch", "Fetch" ), "repo-fetch" );
1780
1781 if ( gitBranch() != branch.name ) {
1782 menuAdd( menu, "git-checkout", i18n( "git_checkout_ellipsis", "Check Out..." ),
1783 "git-fetch" );
1784 }
1785
1786 if ( branch.type == Git::RefType::Head ) {
1787 menuAdd( menu, "git-branch-rename", i18n( "git_rename", "Rename" ), "", { KEY_F2 } );
1788 menuAdd( menu, "git-pull", i18n( "git_pull", "Pull" ), "repo-pull" );
1789 if ( branch.ahead )
1790 menuAdd( menu, "git-push", i18n( "git_push", "Push" ), "repo-push" );
1791 if ( branch.behind )
1792 menuAdd( menu, "git-fast-forward-merge",
1793 i18n( "git_fast_forward_merge", "Fast Forward Merge" ) );
1794 menu->addSeparator();
1795 menuAdd( menu, "git-branch-delete", i18n( "git_delete_branch", "Delete" ), "remove" );
1796 }
1797
1798 menuAdd( menu, "git-merge-branch", i18n( "git_merge_branch", "Merge Branch" ),
1799 "git-merge" );
1800 menuAdd( menu, "git-create-branch", i18n( "git_create_branch", "Create Branch" ),
1801 "repo-forked", { KEY_F7 } );
1802 } else {
1803 menuAdd( menu, "git-stash-apply", i18n( "git_apply_stash", "Apply Stash" ),
1804 "git-stash-apply" );
1805 menuAdd( menu, "git-stash-drop", i18n( "git_drop_stash", "Drop Stash" ), "git-stash-pop" );
1806 }
1807
1808 menu->on( Event::OnItemClicked, [this, branch]( const Event* event ) {
1809 if ( !mGit )
1810 return;
1811 UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
1812 std::string id( item->getId() );
1813 if ( id == "git-checkout" ) {
1814 checkout( branch );
1815 } else if ( id == "git-pull" ) {
1816 pull( repoSelected() );
1817 } else if ( id == "git-push" ) {
1818 push( repoSelected() );
1819 } else if ( id == "git-branch-delete" ) {
1820 branchDelete( branch );
1821 } else if ( id == "git-branch-rename" ) {
1822 branchRename( branch );
1823 } else if ( id == "git-fetch" ) {
1824 fetch( repoSelected() );
1825 } else if ( id == "git-fast-forward-merge" ) {
1826 fastForwardMerge( branch );
1827 } else if ( id == "git-create-branch" ) {
1828 branchCreate();
1829 } else if ( id == "git-stash-apply" ) {
1830 stashApply( branch );
1831 } else if ( id == "git-stash-drop" ) {

Callers

nothing calls this directly

Calls 7

addSeparatorMethod · 0.80
getNodeMethod · 0.80
showOverMouseCursorMethod · 0.80
getIdMethod · 0.65
NewFunction · 0.50
setIdMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected