Sha256: 10afc4be517773c5dfa0473a846926a8b0705f113e426251d477661a7a560779

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'pivotal-github/command'
require 'pivotal-github/finished_command'

class StoryPullRequest < FinishedCommand

  def parser
    OptionParser.new do |opts|
      opts.banner = "Usage: git story-pull-request [options]"
      opts.on("-f", "--force", "override unfinished story warning") do |opt|
        self.options.run = opt
      end
      opts.on("-s", "--skip", "skip `git story-push`") do |opt|
        self.options.skip = opt
      end
      opts.on_tail("-h", "--help", "this usage guide") do
        puts opts.to_s; exit 0
      end
    end
  end

  # Returns a command appropriate for executing at the command line
  # I.e., 'open https://www.pivotaltracker.com/story/show/6283185'
  def cmd
    if skip?
      "open #{uri}"
    else
      "git story-push && open #{uri}"
    end
  end

  def uri
    "#{origin_uri}/pull/new/#{story_branch}"
  end

  private

    # Returns the remote URI for the repository
    # E.g., https://github.com/mhartl/pivotal-github
    def origin_uri
      `git config --get remote.origin.url`.strip.chomp('.git')
    end

    def skip?
      options.skip
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pivotal-github-0.6.9 lib/pivotal-github/story_pull_request.rb
pivotal-github-0.6.8 lib/pivotal-github/story_pull_request.rb
pivotal-github-0.6.7 lib/pivotal-github/story_pull_request.rb