| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent deb9ad8 commit 1712ab5
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,51 +5,51 @@ class PullRequest < API | |||
| 5 | 5 | ||
| 6 | 6 | class << self | |
| 7 | 7 | ||
| 8 | - def list(user, repo, params, format) | ||
| 9 | - output format do | ||
| 10 | - github_api.pull_requests.list user, repo, params | ||
| 8 | + def list(user, repo, params, options) | ||
| 9 | + output options[:format], options[:quiet] do | ||
| 10 | + github_api(options).pull_requests.list user, repo, params | ||
| 11 | 11 | end | |
| 12 | 12 | end | |
| 13 | 13 | ||
| 14 | - def get(user, repo, number, params, format) | ||
| 15 | - output format do | ||
| 16 | - github_api.pull_requests.get user, repo, number, params | ||
| 14 | + def get(user, repo, number, params, options) | ||
| 15 | + output options[:format], options[:quiet] do | ||
| 16 | + github_api(options).pull_requests.get user, repo, number, params | ||
| 17 | 17 | end | |
| 18 | 18 | end | |
| 19 | 19 | ||
| 20 | - def create(user, repo, params, format) | ||
| 21 | - output format do | ||
| 22 | - github_api.pull_requests.create user, repo, params | ||
| 20 | + def create(user, repo, params, options) | ||
| 21 | + output options[:format], options[:quiet] do | ||
| 22 | + github_api(options).pull_requests.create user, repo, params | ||
| 23 | 23 | end | |
| 24 | 24 | end | |
| 25 | 25 | ||
| 26 | - def update(user, repo, number, params, format) | ||
| 27 | - output format do | ||
| 28 | - github_api.pull_requests.update user, repo, number, params | ||
| 26 | + def update(user, repo, number, params, options) | ||
| 27 | + output options[:format], options[:quiet] do | ||
| 28 | + github_api(options).pull_requests.update user, repo, number, params | ||
| 29 | 29 | end | |
| 30 | 30 | end | |
| 31 | 31 | ||
| 32 | - def commits(user, repo, number, params, format) | ||
| 33 | - output format do | ||
| 34 | - github_api.pull_requests.commits user, repo, number, params | ||
| 32 | + def commits(user, repo, number, params, options) | ||
| 33 | + output options[:format], options[:quiet] do | ||
| 34 | + github_api(options).pull_requests.commits user, repo, number, params | ||
| 35 | 35 | end | |
| 36 | 36 | end | |
| 37 | 37 | ||
| 38 | - def files(user, repo, number, params, format) | ||
| 39 | - output format do | ||
| 40 | - github_api.pull_requests.files user, repo, number, params | ||
| 38 | + def files(user, repo, number, params, options) | ||
| 39 | + output options[:format], options[:quiet] do | ||
| 40 | + github_api(options).pull_requests.files user, repo, number, params | ||
| 41 | 41 | end | |
| 42 | 42 | end | |
| 43 | 43 | ||
| 44 | - def merged(user, repo, number, params, format) | ||
| 45 | - output format do | ||
| 46 | - github_api.pull_requests.merged? user, repo, number, params | ||
| 44 | + def merged(user, repo, number, params, options) | ||
| 45 | + output options[:format], options[:quiet] do | ||
| 46 | + github_api(options).pull_requests.merged? user, repo, number, params | ||
| 47 | 47 | end | |
| 48 | 48 | end | |
| 49 | 49 | ||
| 50 | - def merge(user, repo, number, params, format) | ||
| 51 | - output format do | ||
| 52 | - github_api.pull_requests.merge user, repo, number, params | ||
| 50 | + def merge(user, repo, number, params, options) | ||
| 51 | + output options[:format], options[:quiet] do | ||
| 52 | + github_api(options).pull_requests.merge user, repo, number, params | ||
| 53 | 53 | end | |
| 54 | 54 | end | |
| 55 | 55 | end | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,12 +7,18 @@ class Commands::PullRequests < Command | |||
| 7 | 7 | ||
| 8 | 8 | desc 'list <user> <repo>', 'List all Pull Requests' | |
| 9 | 9 | def list(user, repo) | |
| 10 | - PullRequest.list user, repo, options[:params], options[:format] | ||
| 10 | + global_options = options.dup | ||
| 11 | + params = options[:params].dup | ||
| 12 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 13 | + PullRequest.list user, repo, params, global_options | ||
| 11 | 14 | end | |
| 12 | 15 | ||
| 13 | 16 | desc 'get <user> <repo> <number>', 'Get a Pull Request' | |
| 14 | 17 | def get(user, repo, number) | |
| 15 | - PullRequest.get user, repo, number, options[:params], options[:format] | ||
| 18 | + global_options = options.dup | ||
| 19 | + params = options[:params].dup | ||
| 20 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 21 | + PullRequest.get user, repo, number, params, global_options | ||
| 16 | 22 | end | |
| 17 | 23 | ||
| 18 | 24 | desc 'create <user> <repo>', 'Create a new Pull Request' | |
@@ -25,13 +31,15 @@ def get(user, repo, number) | |||
| 25 | 31 | option :issue, :type => :string, | |
| 26 | 32 | :desc => "Issue number in this repository to turn into a Pull Request" | |
| 27 | 33 | def create(user, repo) | |
| 34 | + global_options = options.dup | ||
| 28 | 35 | params = options[:params].dup | |
| 29 | 36 | params['title'] = options[:title] if options[:title] | |
| 30 | 37 | params['body'] = options[:body] if options[:body] | |
| 31 | 38 | params['base'] = options[:base] if options[:base] | |
| 32 | 39 | params['head'] = options[:head] if options[:head] | |
| 33 | 40 | params['issue'] = options[:issue] if options[:issue] | |
| 34 | - PullRequest.create user, repo, params, options[:format] | ||
| 41 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 42 | + PullRequest.create user, repo, params, global_options | ||
| 35 | 43 | end | |
| 36 | 44 | ||
| 37 | 45 | desc 'update <user> <repo> <number>', 'Update a Pull Request' | |
@@ -40,31 +48,45 @@ def create(user, repo) | |||
| 40 | 48 | option :state, :type => :string, | |
| 41 | 49 | :desc => "State of this Pull Request. Valid values are open and closed" | |
| 42 | 50 | def update(user, repo, number) | |
| 51 | + global_options = options.dup | ||
| 43 | 52 | params = options[:params].dup | |
| 44 | 53 | params['title'] = options[:title] if options[:title] | |
| 45 | 54 | params['body'] = options[:body] if options[:body] | |
| 46 | 55 | params['state'] = options[:state] if options[:state] | |
| 47 | - PullRequest.update user, repo, number, params, options[:format] | ||
| 56 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 57 | + PullRequest.update user, repo, number, params, global_options | ||
| 48 | 58 | end | |
| 49 | 59 | ||
| 50 | 60 | desc 'commits <user> <repo> <number>', 'List commits on a Pull Request' | |
| 51 | 61 | def commits(user, repo, number) | |
| 52 | - PullRequest.commits user, repo, number, options[:params], options[:format] | ||
| 62 | + global_options = options.dup | ||
| 63 | + params = options[:params].dup | ||
| 64 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 65 | + PullRequest.commits user, repo, number, params, global_options | ||
| 53 | 66 | end | |
| 54 | 67 | ||
| 55 | 68 | desc 'files <user> <repo> <number>', 'List Pull Requests Files' | |
| 56 | 69 | def files(user, repo, number) | |
| 57 | - PullRequest.files user, repo, number, options[:params], options[:format] | ||
| 70 | + global_options = options.dup | ||
| 71 | + params = options[:params].dup | ||
| 72 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 73 | + PullRequest.files user, repo, number, params, global_options | ||
| 58 | 74 | end | |
| 59 | 75 | ||
| 60 | 76 | desc 'merged <user> <repo> <number>', 'Get if a pull request has been merged' | |
| 61 | 77 | def merged(user, repo, number) | |
| 62 | - PullRequest.merged user, repo, number, options[:params], options[:format] | ||
| 78 | + global_options = options.dup | ||
| 79 | + params = options[:params].dup | ||
| 80 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 81 | + PullRequest.merged user, repo, number, params, global_options | ||
| 63 | 82 | end | |
| 64 | 83 | ||
| 65 | 84 | desc 'merge <user> <repo> <number>', 'Merge a pull request' | |
| 66 | 85 | def merge(user, repo, number) | |
| 67 | - PullRequest.merge user, repo, number, options[:params], options[:format] | ||
| 86 | + global_options = options.dup | ||
| 87 | + params = options[:params].dup | ||
| 88 | + Util.hash_without!(global_options, params.keys + ['params']) | ||
| 89 | + PullRequest.merge user, repo, number, params, global_options | ||
| 68 | 90 | end | |
| 69 | 91 | ||
| 70 | 92 | end # PullRequests | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | require 'spec_helper' | |
| 4 | 4 | ||
| 5 | 5 | describe GithubCLI::Commands::PullRequests do | |
| 6 | - let(:format) { 'table' } | ||
| 6 | + let(:format) { {'format' => 'table'} } | ||
| 7 | 7 | let(:user) { 'peter-murach' } | |
| 8 | 8 | let(:repo) { 'github_cli' } | |
| 9 | 9 | let(:number) { 1 } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments