Sha256: aba9dc2cde29c4707a18989d42fd6a3ea550a402379222059be5bf5b8c1ea9a8

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Cp8Cli
  class Story
    require "shellwords"

    def start
      checkout_branch
      create_empty_commit
      push_branch
      create_wip_pull_request
      assign
      Command.title "Created WIP PR, run `cp8 open` to view."
    end

    private

      def checkout_branch
        branch.checkout
      end

      def create_empty_commit
        Command.run "git commit --allow-empty -m#{commit_message}", title: "Creating initial commit"
      end

      def commit_message
        escaped_title
      end

      def escaped_title
        Shellwords.escape(title)
      end

      def push_branch
        branch.push
      end

      def create_wip_pull_request
        Github::PullRequest.create(
          from: branch.name,
          title: PullRequestTitle.new(title, prefixes: :wip).run,
          body: PullRequestBody.new(self).run
        )
      end

      def branch
        @_branch ||= Branch.new(branch_name)
      end

      def branch_name
        BranchName.new(user: user, story: self).to_s
      end

      def user
        @_user ||= CurrentUser.new
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cp8_cli-8.2.1 lib/cp8_cli/story.rb