Sha256: 79965498c715b96c5d7d167de84ca79a7c5f4531f0d1b0225464095bfc5a138c

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module GitPivotalTracker
  class Finish < Base

    def run!
      return 1 if super

      unless story_id
        puts "Branch name must contain a Pivotal Tracker story id"
        return 1
      end

      if options[:rebase]
        puts "Fetching origin and rebasing #{current_branch}"
        log repository.git.checkout({:raise => true}, integration_branch)
        log repository.git.pull({:raise => true})
        log repository.git.rebase({:raise => true}, integration_branch, current_branch)
      end

      puts "Merging #{current_branch} into #{integration_branch}"
      log repository.git.checkout({:raise => true}, integration_branch)

      merge_options = {:raise => true}
      merge_options[:no_ff] = true unless options[:fast_forward]
      log repository.git.merge(merge_options, current_branch)

      puts "Pushing #{integration_branch}"
      log repository.git.push({:raise => true})

      puts "Marking Story #{story_id} as finished..."
      if story.update(:current_state => finished_state)
        puts "Success"
        return 0
      else
        puts "Unable to mark Story #{story_id} as finished"
        return 1
      end
    end

    private

    def finished_state
      story.story_type == "chore" ? "accepted" : "finished"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_pivotal_tracker-0.0.7 lib/git_pivotal_tracker/finish.rb
git_pivotal_tracker-0.0.6 lib/git_pivotal_tracker/finish.rb
git_pivotal_tracker-0.0.5 lib/git_pivotal_tracker/finish.rb