Module: RuVim::Git::Handler
- Includes:
- RuVim::Gh::Link::HandlerMethods, Blame::HandlerMethods, Branch::HandlerMethods, Commit::HandlerMethods, Diff::HandlerMethods, Grep::HandlerMethods, Log::HandlerMethods, Status::HandlerMethods
- Included in:
- RuVim::GlobalCommands
- Defined in:
- lib/ruvim/git/handler.rb
Constant Summary collapse
- GIT_SUBCOMMANDS =
{ "blame" => :git_blame, "blameprev" => :git_blame_prev, "blameback" => :git_blame_back, "blamecommit" => :git_blame_commit, "status" => :git_status, "diff" => :git_diff, "log" => :git_log, "branch" => :git_branch, "checkout" => :git_branch_execute_checkout, "commit" => :git_commit, "grep" => :git_grep, }.freeze
- GH_SUBCOMMANDS =
{ "link" => :gh_link, "browse" => :gh_browse, "pr" => :gh_pr, }.freeze
Instance Method Summary collapse
- #enter_git_command_mode(ctx) ⇒ Object
- #ex_gh(ctx, argv: [], kwargs: {}) ⇒ Object
- #ex_git(ctx, argv: []) ⇒ Object
- #git_close_buffer(ctx) ⇒ Object
Methods included from RuVim::Gh::Link::HandlerMethods
Methods included from Grep::HandlerMethods
#git_grep, #git_grep_open_file
Methods included from Commit::HandlerMethods
#git_commit, #git_commit_execute
Methods included from Branch::HandlerMethods
#git_branch, #git_branch_checkout, #git_branch_execute_checkout
Methods included from Log::HandlerMethods
Methods included from Diff::HandlerMethods
#git_diff, #git_diff_open_file
Methods included from Status::HandlerMethods
#git_status, #git_status_open_file
Methods included from Blame::HandlerMethods
#git_blame, #git_blame_back, #git_blame_commit, #git_blame_prev
Instance Method Details
#enter_git_command_mode(ctx) ⇒ Object
50 51 52 53 54 |
# File 'lib/ruvim/git/handler.rb', line 50 def enter_git_command_mode(ctx, **) ctx.editor.enter_command_line_mode(":") ctx.editor.command_line.replace_text("git ") ctx.editor. end |
#ex_gh(ctx, argv: [], kwargs: {}) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ruvim/git/handler.rb', line 74 def ex_gh(ctx, argv: [], kwargs: {}, **) raise RuVim::CommandError, "Restricted mode: :gh is disabled" if ctx.editor.respond_to?(:restricted_mode?) && ctx.editor.restricted_mode? sub = argv.first.to_s.downcase if sub.empty? ctx.editor.echo("GitHub subcommands: #{GH_SUBCOMMANDS.keys.join(', ')}") return end method = GH_SUBCOMMANDS[sub] unless method run_shell_fallback(ctx, "gh", argv) return end public_send(method, ctx, argv: argv[1..], kwargs: kwargs, bang: false, count: 1) end |
#ex_git(ctx, argv: []) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ruvim/git/handler.rb', line 56 def ex_git(ctx, argv: [], **) raise RuVim::CommandError, "Restricted mode: :git is disabled" if ctx.editor.respond_to?(:restricted_mode?) && ctx.editor.restricted_mode? sub = argv.first.to_s.downcase if sub.empty? ctx.editor.echo("Git subcommands: #{GIT_SUBCOMMANDS.keys.join(', ')}") return end method = GIT_SUBCOMMANDS[sub] unless method run_shell_fallback(ctx, "git", argv) return end public_send(method, ctx, argv: argv[1..], kwargs: {}, bang: false, count: 1) end |
#git_close_buffer(ctx) ⇒ Object
92 93 94 95 96 |
# File 'lib/ruvim/git/handler.rb', line 92 def git_close_buffer(ctx, **) buf_id = ctx.buffer.id ctx.editor.git_stream_stop_handler&.call(buf_id) ctx.editor.delete_buffer(buf_id) end |