@@ -634,8 +634,94 @@ function GitTool.cherry_pick(commit_hash)
634634 if not commit_hash then
635635 return false , " Commit hash is required for cherry-pick"
636636 end
637+
638+ if not is_git_repo () then
639+ return false , " Not in a git repository"
640+ end
641+
637642 local cmd = " git cherry-pick --no-edit " .. vim .fn .shellescape (commit_hash )
638- return execute_git_command (cmd )
643+ local output = vim .fn .system (cmd )
644+ local exit_code = vim .v .shell_error
645+
646+ if exit_code == 0 then
647+ return true , output
648+ else
649+ if output :match (" CONFLICT" ) or output :match (" conflict" ) then
650+ return false ,
651+ " Cherry-pick conflict detected. Please resolve the conflicts manually.\n "
652+ .. " Options:\n "
653+ .. " • Use 'cherry_pick_continue' after resolving conflicts\n "
654+ .. " • Use 'cherry_pick_abort' to cancel the cherry-pick\n "
655+ .. " • Use 'cherry_pick_skip' to skip this commit"
656+ else
657+ return false , output
658+ end
659+ end
660+ end
661+
662+ --- Abort cherry-pick operation
663+ --- @return boolean success , string output
664+ function GitTool .cherry_pick_abort ()
665+ if not is_git_repo () then
666+ return false , " Not in a git repository"
667+ end
668+
669+ local cmd = " git cherry-pick --abort"
670+ local output = vim .fn .system (cmd )
671+ local exit_code = vim .v .shell_error
672+
673+ if exit_code == 0 then
674+ return true , " Cherry-pick aborted successfully"
675+ else
676+ if output :match (" no cherry%-pick" ) or output :match (" not in progress" ) then
677+ return false , " No cherry-pick in progress to abort"
678+ end
679+ return false , output
680+ end
681+ end
682+
683+ --- Continue cherry-pick after resolving conflicts
684+ --- @return boolean success , string output
685+ function GitTool .cherry_pick_continue ()
686+ if not is_git_repo () then
687+ return false , " Not in a git repository"
688+ end
689+
690+ local cmd = " git cherry-pick --continue"
691+ local output = vim .fn .system (cmd )
692+ local exit_code = vim .v .shell_error
693+
694+ if exit_code == 0 then
695+ return true , " Cherry-pick continued successfully"
696+ else
697+ if output :match (" CONFLICT" ) or output :match (" conflict" ) then
698+ return false , " Conflicts still exist. Please resolve all conflicts before continuing."
699+ elseif output :match (" no cherry%-pick" ) or output :match (" not in progress" ) then
700+ return false , " No cherry-pick in progress to continue"
701+ end
702+ return false , output
703+ end
704+ end
705+
706+ --- Skip current commit in cherry-pick
707+ --- @return boolean success , string output
708+ function GitTool .cherry_pick_skip ()
709+ if not is_git_repo () then
710+ return false , " Not in a git repository"
711+ end
712+
713+ local cmd = " git cherry-pick --skip"
714+ local output = vim .fn .system (cmd )
715+ local exit_code = vim .v .shell_error
716+
717+ if exit_code == 0 then
718+ return true , " Current commit skipped successfully"
719+ else
720+ if output :match (" no cherry%-pick" ) or output :match (" not in progress" ) then
721+ return false , " No cherry-pick in progress to skip"
722+ end
723+ return false , output
724+ end
639725end
640726
641727--- Revert a commit
@@ -714,15 +800,62 @@ function GitTool.merge(branch)
714800 if exit_code == 0 then
715801 return true , output
716802 else
717- if output :match (" CONFLICT" ) then
803+ if output :match (" CONFLICT" ) or output : match ( " conflict " ) then
718804 return false ,
719- " Merge conflict detected. Please resolve the conflicts manually. You can use 'git merge --abort' to cancel."
805+ " Merge conflict detected. Please resolve the conflicts manually.\n "
806+ .. " Options:\n "
807+ .. " • Use 'merge_continue' after resolving conflicts\n "
808+ .. " • Use 'merge_abort' to cancel the merge"
720809 else
721810 return false , output
722811 end
723812 end
724813end
725814
815+ --- Abort merge operation
816+ --- @return boolean success , string output
817+ function GitTool .merge_abort ()
818+ if not is_git_repo () then
819+ return false , " Not in a git repository"
820+ end
821+
822+ local cmd = " git merge --abort"
823+ local output = vim .fn .system (cmd )
824+ local exit_code = vim .v .shell_error
825+
826+ if exit_code == 0 then
827+ return true , " Merge aborted successfully"
828+ else
829+ if output :match (" not merging" ) or output :match (" no merge" ) then
830+ return false , " No merge in progress to abort"
831+ end
832+ return false , output
833+ end
834+ end
835+
836+ --- Continue merge after resolving conflicts
837+ --- @return boolean success , string output
838+ function GitTool .merge_continue ()
839+ if not is_git_repo () then
840+ return false , " Not in a git repository"
841+ end
842+
843+ local cmd = " git merge --continue"
844+ local output = vim .fn .system (cmd )
845+ local exit_code = vim .v .shell_error
846+
847+ if exit_code == 0 then
848+ return true , " Merge continued successfully"
849+ else
850+ if output :match (" CONFLICT" ) or output :match (" conflict" ) then
851+ return false , " Conflicts still exist. Please resolve all conflicts before continuing."
852+ elseif output :match (" not merging" ) or output :match (" no merge" ) then
853+ return false , " No merge in progress to continue"
854+ end
855+ return false , output
856+ end
857+ end
858+
726859--- Generate release notes between two tags
727860--- @param from_tag string | nil Starting tag (if not provided , uses second latest tag )
728861--- @param to_tag string | nil Ending tag (if not provided , uses latest tag )
0 commit comments