Class: Ace::Git::CLI::Commands::Status
- Inherits:
-
Support::Cli::Command
- Object
- Support::Cli::Command
- Ace::Git::CLI::Commands::Status
- Includes:
- Support::Cli::Base
- Defined in:
- lib/ace/git/cli/commands/status.rb
Overview
ace-support-cli command for showing repository status
Instance Method Summary collapse
Instance Method Details
#call(**options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ace/git/cli/commands/status.rb', line 30 def call(**) # Determine PR settings based on --no-pr flag skip_pr = [:no_pr] commits_limit = [:commits] || Ace::Git.commits_limit # Load status = { include_pr: !skip_pr, include_pr_activity: !skip_pr, include_commits: commits_limit > 0, commits_limit: commits_limit, timeout: Ace::Git.network_timeout } status = Organisms::RepoStatusLoader.load() # Check for errors if status.branch.nil? && status.repository_type == :not_git raise Ace::Support::Cli::Error.new("Not in a git repository") end # Output based on format case [:format] when "json" puts JSON.pretty_generate(status.to_h) else puts status.to_markdown end # Include diff if requested if [:with_diff] && status.has_pr? begin diff_result = Molecules::PrMetadataFetcher.fetch_diff( status.["number"].to_s ) if diff_result[:success] puts "" puts "## PR Diff" puts "" puts "```diff" puts diff_result[:diff] puts "```" end rescue Ace::Git::Error # Silently skip diff if it fails end end rescue Ace::Git::Error => e raise Ace::Support::Cli::Error.new(e.) end |