Class: PullRequestAi::Repo::Prompt
- Inherits:
-
Object
- Object
- PullRequestAi::Repo::Prompt
- Defined in:
- lib/pull_request_ai/repo/prompt.rb
Instance Method Summary collapse
- #changes_between(branch1, branch2) ⇒ Object
- #configured? ⇒ Boolean
- #current_branch ⇒ Object
- #remote_branches ⇒ Object
- #remote_name ⇒ Object
- #remote_url(name) ⇒ Object
Instance Method Details
#changes_between(branch1, branch2) ⇒ Object
28 29 30 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 28 def changes_between(branch1, branch2) %x(git diff --patch #{branch1}..#{branch2}).strip end |
#configured? ⇒ Boolean
6 7 8 9 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 6 def configured? %x(git rev-parse --is-inside-work-tree > /dev/null 2>&1) $CHILD_STATUS.exitstatus == 0 end |
#current_branch ⇒ Object
11 12 13 14 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 11 def current_branch name = %x(git rev-parse --abbrev-ref HEAD).chomp name == 'HEAD' ? %x(git rev-parse --short HEAD).chomp : name end |
#remote_branches ⇒ Object
24 25 26 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 24 def remote_branches %x(git branch --remotes --no-color).split("\n") end |
#remote_name ⇒ Object
16 17 18 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 16 def remote_name %x(git remote).strip end |
#remote_url(name) ⇒ Object
20 21 22 |
# File 'lib/pull_request_ai/repo/prompt.rb', line 20 def remote_url(name) %x(git config --get remote.#{name}.url).strip end |