Class: Feature::Land
- Inherits:
-
Object
- Object
- Feature::Land
- Includes:
- Feature
- Defined in:
- lib/straight_line/common/feature/land.rb
Overview
Merges the feature to master and pushes it
Instance Method Summary collapse
-
#initialize ⇒ Land
constructor
A new instance of Land.
- #land(_args = {}) ⇒ Object
- #pull_request_closed?(feature_name) ⇒ Boolean
Methods included from Feature
#changes_committed?, #current_feature
Constructor Details
#initialize ⇒ Land
Returns a new instance of Land.
13 14 15 16 17 18 19 20 21 |
# File 'lib/straight_line/common/feature/land.rb', line 13 def initialize if current_feature == 'master' raise UserError, 'Failed to create diff: you\'re on the master branch' end return if changes_committed? raise UserError, 'Commit your changes before creating a diff' end |
Instance Method Details
#land(_args = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/straight_line/common/feature/land.rb', line 23 def land(_args = {}) feature_name = current_feature pull_cmd = GitCommands::Pull.new('master') pull_cmd.run GitCommands::Merge.new(feature_name, 'master').run begin GitCommands::Commit.new("Merge master into #{feature_name}", '').run rescue StandardError => e unless e..match %r[nothing to commit] raise e end end GitCommands::Push.new(feature_name).run if pull_request_closed?(feature_name) Util.logger.info %{#{feature_name} was merged in github. You're repo is up-to-date with remote} else GitCommands::Merge.new('master', feature_name).run GitCommands::Push.new('master').run end GitCommands::Push.new(feature_name, delete: true).run Command.new('git checkout master').run Util.logger.info 'Changes landed to master, on master branch now.' end |
#pull_request_closed?(feature_name) ⇒ Boolean
49 50 51 52 |
# File 'lib/straight_line/common/feature/land.rb', line 49 def pull_request_closed?(feature_name) p = Github.pull_request_for_feature feature_name p.nil? || p.state == 'closed' end |