lib/ninny/commands/pull_request_merge.rb in ninny-0.1.9 vs lib/ninny/commands/pull_request_merge.rb in ninny-0.1.10

- old
+ new

@@ -12,28 +12,30 @@ @branch_type = options[:branch_type] || Ninny::Git::STAGING_PREFIX self.pull_request_id = pull_request_id self.options = options end - def execute(input: $stdin, output: $stdout) - if (!pull_request_id) + def execute(*) + unless pull_request_id current = Ninny.repo.current_pull_request self.pull_request_id = current.number if current end + self.pull_request_id ||= select_pull_request check_out_branch merge_pull_request comment_about_merge end - private def select_pull_request + def select_pull_request choices = Ninny.repo.open_pull_requests.map { |pr| { name: pr.title, value: pr.number } } prompt.select("Which #{Ninny.repo.pull_request_label}?", choices) end + private :select_pull_request - # Public: Check out the branch + # Public: Check out the branch def check_out_branch Ninny.git.check_out(branch_to_merge_into, false) Ninny.git.track_current_branch rescue Ninny::Git::NoBranchOfType prompt.say "No #{branch_type} branch available. Creating one now." @@ -58,12 +60,14 @@ end # Public: Find the pull request # # Returns a Ninny::Repository::PullRequest + # rubocop:disable Lint/DuplicateMethods def pull_request @pull_request ||= Ninny.repo.pull_request(pull_request_id) end + # rubocop:enable Lint/DuplicateMethods # Public: Find the branch # # Returns a String def branch_to_merge_into