Sha256: ccfcfcc4e6b04c25f8d7ff6c4d66f2d3324e3c7716fb91b3710b26e4dfc3f625

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 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.force = 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/62831853'
  def cmd
    "git pull-request"
  end

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

  private

    # Returns the raw remote location for the repository.
    # E.g., http://github.com/mhartl/pivotal-github or
    # git@github.com:mhartl/pivotal-github
    def remote_location
      `git config --get remote.origin.url`.strip.chomp('.git')
    end

    # Returns the remote URI for the repository.
    # Both https://... and git@... remote formats are supported.
    def origin_uri
      remote_location.sub(/^git@(.+?):(.+)$/, 'https://\1/\2')
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pivotal-github-0.8.1 lib/pivotal-github/story_pull_request.rb