Sha256: 0d42c5bf0bbc1b8d107e700493c4ab5096a17ce635c2fe4c8dea3d3238dbafd2

Contents?: true

Size: 945 Bytes

Versions: 3

Compression:

Stored size: 945 Bytes

Contents

require "cp8_cli/storyable"

module Cp8Cli
  class AdhocStory
    include Storyable
    attr_reader :title

    def initialize(title)
      @title = title
    end

    def summary
      nil # noop for now
    end

    def start
      create_empty_commit
      push_branch
      create_wip_pull_request
    end

    def short_link
      nil # noop for now
    end

    def pr_title
      PullRequestTitle.new(title, prefixes: [:wip]).run
    end

    private

      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(
          title: pr_title,
          from: branch.name,
          to: branch.target
        )
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cp8_cli-6.0.1 lib/cp8_cli/adhoc_story.rb
cp8_cli-6.0.0 lib/cp8_cli/adhoc_story.rb
cp8_cli-5.0.0 lib/cp8_cli/adhoc_story.rb