Skip to content

Commit

Permalink
Added Git push.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Jan 23, 2024
1 parent bdd018f commit 857fb48
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/tools/ecode/plugins/git/git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/ecode/plugins/git/git.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/tools/ecode/plugins/git/gitplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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(); } );
}
Expand Down Expand Up @@ -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" );
}
}

Expand All @@ -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" ) {
Expand Down
2 changes: 2 additions & 0 deletions src/tools/ecode/plugins/git/gitplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class GitPlugin : public PluginBase {

void pull();

void push();

void fetch();

void branchCreate();
Expand Down

0 comments on commit 857fb48

Please sign in to comment.