Sha256: 8077344ec240efd47ee3e1d877b1e69c8799e983cf0954335e89dab6a0f57266

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module Cp8Cli
  class Story
    def start
      checkout_branch
      create_empty_commit
      push_branch
      create_wip_pull_request
      assign
      Command.say "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}\""
      end

      def commit_message
        "Started: #{escaped_title}"
      end

      def escaped_title
        title.gsub('"', '\"')
      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

2 entries across 2 versions & 1 rubygems

Version Path
cp8_cli-8.0.1 lib/cp8_cli/story.rb
cp8_cli-8.0.0 lib/cp8_cli/story.rb