Class: Toolshed::Commands::CreatePullRequest

Inherits:
Base
  • Object
show all
Defined in:
lib/toolshed/commands/create_pull_request.rb

Overview

Allow a user to create pull request based on information in .toolshedrc and prompts

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

parse, #read_user_input, #read_user_input_body, #read_user_input_password, #read_user_input_title, #use_project_id, #use_ticket_tracker_by_type, #use_ticket_tracker_project_id, #use_ticket_tracker_project_name

Constructor Details

#initialize(options = {}) ⇒ CreatePullRequest

Returns a new instance of CreatePullRequest.



15
16
17
18
19
# File 'lib/toolshed/commands/create_pull_request.rb', line 15

def initialize(options = {})
  super(options)
  self.ticket_tracker_class = nil
  self.pull_request_url = ''
end

Instance Attribute Details

#git_toolObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def git_tool
  @git_tool
end

#pull_request_bodyObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def pull_request_body
  @pull_request_body
end

#pull_request_titleObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def pull_request_title
  @pull_request_title
end

#pull_request_urlObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def pull_request_url
  @pull_request_url
end

#ticket_idObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_id
  @ticket_id
end

#ticket_trackerObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_tracker
  @ticket_tracker
end

#ticket_tracker_classObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_tracker_class
  @ticket_tracker_class
end

#ticket_tracker_project_idObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_tracker_project_id
  @ticket_tracker_project_id
end

#ticket_tracking_titleObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_tracking_title
  @ticket_tracking_title
end

#ticket_tracking_urlObject

rubocop:disable ClassLength, LineLength



9
10
11
# File 'lib/toolshed/commands/create_pull_request.rb', line 9

def ticket_tracking_url
  @ticket_tracking_url
end

Class Method Details

.cli_optionsObject

rubocop:disable Metrics/MethodLength



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/toolshed/commands/create_pull_request.rb', line 21

def self.cli_options # rubocop:disable Metrics/MethodLength
  {
    banner: 'Usage: push_branch [options]',
    options: {
      tool: {
        short_on: '-a'
      },
      ticket_system: {
        short_on: '-m'
      },
      use_defaults: {
        short_on: '-d'
      },
      title: {
        short_on: '-t'
      },
      body: {
        short_on: '-b'
      },
      skip_ticket: {
        short_on: '-s',
        default: true
      }
    }
  }
end

Instance Method Details

#branchObject



48
49
50
# File 'lib/toolshed/commands/create_pull_request.rb', line 48

def branch
  @branch ||= Toolshed::Git::Branch.new
end

#execute(_args, options = {}) ⇒ Object



52
53
54
55
56
# File 'lib/toolshed/commands/create_pull_request.rb', line 52

def execute(_args, options = {})
  output_begining_messages
  options = execute_ticket_tracking(options)
  execute_pull_request(options) unless options.nil?
end