Class: Shipit::Cli::Work
- Inherits:
-
Object
- Object
- Shipit::Cli::Work
- Defined in:
- lib/shipit/cli/work.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#global_options ⇒ Object
readonly
Returns the value of attribute global_options.
-
#issue_id ⇒ Object
readonly
Returns the value of attribute issue_id.
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
-
#initialize(issue_id, global_options) ⇒ Work
constructor
A new instance of Work.
-
#perform(target_branch) ⇒ Object
1.
Constructor Details
#initialize(issue_id, global_options) ⇒ Work
Returns a new instance of Work.
14 15 16 17 18 |
# File 'lib/shipit/cli/work.rb', line 14 def initialize(issue_id, ) @issue_id = issue_id @global_options = @client = .fetch(:client) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/shipit/cli/work.rb', line 7 def client @client end |
#global_options ⇒ Object (readonly)
Returns the value of attribute global_options.
7 8 9 |
# File 'lib/shipit/cli/work.rb', line 7 def @global_options end |
#issue_id ⇒ Object (readonly)
Returns the value of attribute issue_id.
7 8 9 |
# File 'lib/shipit/cli/work.rb', line 7 def issue_id @issue_id end |
Instance Method Details
#dry_run? ⇒ Boolean
44 45 46 |
# File 'lib/shipit/cli/work.rb', line 44 def dry_run? ["dry_run"] == true end |
#perform(target_branch) ⇒ Object
-
Get issue : docs.gitlab.com/ee/api/issues.html#single-issue
-
Validate issue properties
-
Create branch : docs.gitlab.com/ee/api/branches.html#create-repository-branch
-
First commit : docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
-
New merge request : docs.gitlab.com/ee/api/merge_requests.html#create-mr
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shipit/cli/work.rb', line 25 def perform(target_branch) # 1. Load issue issue = fetch_remote_issue(issue_id).to_hash # 2. Validate issue validate_issue(issue) # 3. Add additional issue attributes enhanced_issue = enhance_issue(issue, target_branch) # 4. Create remote branch & checkout create_source_branch(enhanced_issue) # 5. Create merge request create_merge_request(enhanced_issue) # 6. Motivation! puts "" Shipit::Cli.ascii rescue => e exit_now! e end |