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

Method commit

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

Source from the content-addressed store, hash-verified

828}
829
830void GitPlugin::commit( const std::string& repoPath ) {
831 if ( !mGitStatus.hasStagedChanges( mGit->repoName( repoPath, true ) ) ) {
832 UIMessageBox* msgBox = UIMessageBox::New(
833 UIMessageBox::OK, i18n( "git_nothing_to_commit", "Nothing to Commit" ) );
834 msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } );
835 msgBox->setTitle( i18n( "git_nothing_to_commit", "Nothing to Commit" ) );
836 msgBox->center();
837 msgBox->showWhenReady();
838 return;
839 }
840
841 UIMessageBox* msgBox = UIMessageBox::New( UIMessageBox::TEXT_EDIT,
842 i18n( "git_commit_message", "Commit Message:" ) );
843
844 UITextEdit* txtEdit = msgBox->getTextEdit();
845 txtEdit->setLineWrapType( LineWrapType::Viewport );
846 txtEdit->setLineWrapMode( LineWrapMode::Letter );
847 txtEdit->setText( mLastCommitMsg );
848
849 UICheckBox* chkAmend = UICheckBox::New();
850 chkAmend->setLayoutMargin( Rectf( 0, 8, 0, 0 ) )
851 ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent )
852 ->setLayoutGravity( UI_HALIGN_LEFT | UI_VALIGN_CENTER )
853 ->setClipType( ClipType::None )
854 ->setParent( msgBox->getLayoutCont()->getFirstChild() )
855 ->setId( "git-amend" );
856 chkAmend->setText( i18n( "git_amend", "Amend last commit" ) );
857 chkAmend->toPosition( 2 );
858 chkAmend->setTooltipText( getUISceneNode()->getKeyBindings().getShortcutString(
859 { KEY_A, KeyMod::getDefaultModifier() }, true ) );
860
861 UICheckBox* chkBypassHook = UICheckBox::New();
862 chkBypassHook->setLayoutMargin( Rectf( 0, 8, 0, 0 ) )
863 ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent )
864 ->setLayoutGravity( UI_HALIGN_LEFT | UI_VALIGN_CENTER )
865 ->setClipType( ClipType::None )
866 ->setParent( msgBox->getLayoutCont()->getFirstChild() )
867 ->setId( "git-bypass-hook" );
868 chkBypassHook->setText( i18n( "git_bypass_hook", "Bypass commit hook" ) );
869 chkBypassHook->toPosition( 3 );
870 chkBypassHook->setTooltipText( getUISceneNode()->getKeyBindings().getShortcutString(
871 { KEY_B, KeyMod::getDefaultModifier() }, true ) );
872
873 UICheckBox* chkPush = UICheckBox::New();
874 chkPush->setLayoutMargin( Rectf( 0, 8, 0, 0 ) )
875 ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent )
876 ->setLayoutGravity( UI_HALIGN_LEFT | UI_VALIGN_CENTER )
877 ->setClipType( ClipType::None )
878 ->setParent( msgBox->getLayoutCont()->getFirstChild() )
879 ->setId( "git-push-commit" );
880 chkPush->setText( i18n( "git_push_commit", "Push commit" ) );
881 chkPush->toPosition( 4 );
882 chkPush->setTooltipText( getUISceneNode()->getKeyBindings().getShortcutString(
883 { KEY_P, KeyMod::getDefaultModifier() }, true ) );
884
885 txtEdit->getDocument().setCommand(
886 "commit-amend", [chkAmend] { chkAmend->setChecked( !chkAmend->isChecked() ); } );
887 txtEdit->getKeyBindings().addKeybind( { KEY_L, KeyMod::getDefaultModifier() }, "commit-amend" );

Callers

nothing calls this directly

Calls 15

hasStagedChangesMethod · 0.80
centerMethod · 0.80
showWhenReadyMethod · 0.80
getTextEditMethod · 0.80
setLineWrapTypeMethod · 0.80
setParentMethod · 0.80
setLayoutGravityMethod · 0.80
setLayoutSizePolicyMethod · 0.80
setLayoutMarginMethod · 0.80
getFirstChildMethod · 0.80
getLayoutContMethod · 0.80
toPositionMethod · 0.80

Tested by

no test coverage detected