Added Git push.

This commit is contained in:
Martín Lucas Golini
2024-01-23 20:42:02 -03:00
parent bdd018feec
commit 857fb48fc6
4 changed files with 18 additions and 1 deletions

View File

@@ -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;

View File

@@ -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,

View File

@@ -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" ) {

View File

@@ -131,6 +131,8 @@ class GitPlugin : public PluginBase {
void pull();
void push();
void fetch();
void branchCreate();