diff --git a/src/tools/ecode/plugins/git/git.cpp b/src/tools/ecode/plugins/git/git.cpp index 615178b62..a84dc2ac9 100644 --- a/src/tools/ecode/plugins/git/git.cpp +++ b/src/tools/ecode/plugins/git/git.cpp @@ -140,6 +140,10 @@ Git::Result Git::pull( const std::string& projectDir ) { return gitSimple( "pull", projectDir ); } +Git::Result Git::push( const std::string& projectDir ) { + return gitSimple( "push", projectDir ); +} + Git::CheckoutResult Git::checkout( const std::string& branch, const std::string& projectDir ) const { std::string buf; diff --git a/src/tools/ecode/plugins/git/git.hpp b/src/tools/ecode/plugins/git/git.hpp index b4e2dc862..d09d1c193 100644 --- a/src/tools/ecode/plugins/git/git.hpp +++ b/src/tools/ecode/plugins/git/git.hpp @@ -243,6 +243,8 @@ class Git { Result pull( const std::string& projectDir = "" ); + Result push( const std::string& projectDir = "" ); + CheckoutResult checkout( const std::string& branch, const std::string& projectDir = "" ) const; CheckoutResult checkoutAndCreateLocalBranch( const std::string& remoteBranch, diff --git a/src/tools/ecode/plugins/git/gitplugin.cpp b/src/tools/ecode/plugins/git/gitplugin.cpp index 1501f511a..347bfe877 100644 --- a/src/tools/ecode/plugins/git/gitplugin.cpp +++ b/src/tools/ecode/plugins/git/gitplugin.cpp @@ -972,6 +972,10 @@ void GitPlugin::pull() { runAsync( [this]() { return mGit->pull(); }, true, true ); } +void GitPlugin::push() { + runAsync( [this]() { return mGit->push(); }, true, true ); +} + void GitPlugin::fetch() { runAsync( [this]() { return mGit->fetch(); }, true, true ); } @@ -1002,7 +1006,7 @@ void GitPlugin::commit() { if ( msg.empty() ) return; msgBox->closeWindow(); - runAsync( [this, msg]() { return mGit->commit( msg ); }, false, true ); + runAsync( [this, msg]() { return mGit->commit( msg ); }, true, true ); } ); msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } ); msgBox->setTitle( i18n( "git_commit", "Commit" ) ); @@ -1077,6 +1081,7 @@ void GitPlugin::onRegister( UICodeEditor* editor ) { mTab->setTabSelected(); } ); doc.setCommand( "git-pull", [this] { pull(); } ); + doc.setCommand( "git-push", [this] { push(); } ); doc.setCommand( "git-fetch", [this] { fetch(); } ); doc.setCommand( "git-commit", [this] { commit(); } ); } @@ -1347,6 +1352,8 @@ void GitPlugin::openBranchMenu( const Git::Branch& branch ) { } else { if ( branch.type == Git::RefType::Head ) { addMenuItem( menu, "git-pull", "Pull", "repo-pull" ); + if ( branch.ahead ) + addMenuItem( menu, "git-push", "Push", "repo-push" ); } } @@ -1362,6 +1369,8 @@ void GitPlugin::openBranchMenu( const Git::Branch& branch ) { checkout( branch ); } else if ( id == "git-pull" ) { pull(); + } else if ( id == "git-push" ) { + push(); } else if ( id == "git-branch-delete" ) { branchDelete( branch ); } else if ( id == "git-branch-rename" ) { diff --git a/src/tools/ecode/plugins/git/gitplugin.hpp b/src/tools/ecode/plugins/git/gitplugin.hpp index f296ef136..6a3d3651f 100644 --- a/src/tools/ecode/plugins/git/gitplugin.hpp +++ b/src/tools/ecode/plugins/git/gitplugin.hpp @@ -131,6 +131,8 @@ class GitPlugin : public PluginBase { void pull(); + void push(); + void fetch(); void branchCreate();