Sha256: 5b41bb3f3dc51cae55347afdce0fbfd9f93d3363a33ae277b0f4d335d7f2df54

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

module Cp8Cli
  class Story
    require "shellwords"

    def start
      checkout_branch
      create_empty_commit
      push_branch
      create_draft_pull_request
      assign
      Command.title "Created draft 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_draft_pull_request
        Github::PullRequest.create(
          from: branch.name,
          title: PullRequestTitle.new(title).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

6 entries across 6 versions & 1 rubygems

Version Path
cp8_cli-9.1.1 lib/cp8_cli/story.rb
cp8_cli-9.1.0 lib/cp8_cli/story.rb
cp8_cli-9.0.3 lib/cp8_cli/story.rb
cp8_cli-9.0.2 lib/cp8_cli/story.rb
cp8_cli-9.0.1 lib/cp8_cli/story.rb
cp8_cli-9.0.0 lib/cp8_cli/story.rb