Sha256: 00a0b61583953f8580cd503571739708ca3ed0d519d49b718b3fe57cf4631c75

Contents?: true

Size: 1.82 KB

Versions: 25

Compression:

Stored size: 1.82 KB

Contents

require_relative "issue_creator"
require_relative "../renderer"
require 'tempfile'

module Octopolo
  module GitHub
    class PullRequestCreator < IssueCreator

      # Public: Create a pull request for the given repo with the given options
      #
      # repo_name - Full name ("account/repo") of the repo in question
      # options - Hash of pull request information
      #   title: Title of the pull request
      #   destination_branch: Which branch to merge into
      #   source_branch: Which branch to be merged
      def initialize repo_name, options
        super(repo_name, options)
      end

      # Public: Create the pull request
      #
      # Returns an array with the first element being the pull request's
      # number, the second being a Mash of the response from GitHub's API
      def perform
        result = GitHub.create_pull_request(repo_name, destination_branch, source_branch, title, body)
        # capture the information
        self.number = result.number
        self.data = result
      rescue => e
        raise CannotCreate, e.message
      end

      # Public: Branch to merge the pull request into
      #
      # Returns a String with the branch name
      def destination_branch
        options[:destination_branch] || raise(MissingAttribute)
      end

      # Public: Branch to merge into the destination branch
      #
      # Returns a String with the branch name
      def source_branch
        options[:source_branch] || raise(MissingAttribute)
      end

      # Public: Rendering template for body property
      #
      # Returns Name of template file
      def renderer_template
        Renderer::PULL_REQUEST_BODY
      end


      # Public: Temporary file for body editing
      #
      # Returns Name of temporary file
      def body_edit_temp_name
        'octopolo_pull_request'
      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
octopolo-1.0.2 lib/octopolo/github/pull_request_creator.rb
octopolo-1.0.1 lib/octopolo/github/pull_request_creator.rb
octopolo-1.0.0 lib/octopolo/github/pull_request_creator.rb
octopolo-0.4.1 lib/octopolo/github/pull_request_creator.rb
octopolo-0.4.0 lib/octopolo/github/pull_request_creator.rb