Sha256: 0f0748cbfdf8c84f09b7c4934ab16af227321e070a462b2d45434a3dccaa9163

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Dude
  module Commands
    module PR
      BASE_BRANCH = 'master'

      class Create < Dry::CLI::Command
        desc 'Create PR with custom template description'

        argument :id, required: true, desc: 'The card short ID'

        def call(id:)
          @id = id
          client = CodeManagement::Github::Client.new
          client.create_pull_request(issue: issue, owner: owner, repo: repo, params: params)
        end

        private

        attr_reader :id

        def owner
          repository_name.split('/')[0]
        end

        def issue
          client = ProjectManagement::Client.new
          client.fetch_current_task(id)
        end

        def repo
          repository_name.split('/')[1]
        end

        def params
          {
            head: Git::CurrentBranchName.new.call,
            base: BASE_BRANCH
          }
        end

        def repository_name
          @repository_name ||= Git::RemoteName.new.call
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dude-cli-2.1.0 lib/dude/commands/pr/create.rb
dude-cli-2.1.0.alpha5 lib/dude/commands/pr/create.rb
dude-cli-2.1.0.alpha4 lib/dude/commands/pr/create.rb
dude-cli-2.1.0.alpha3 lib/dude/commands/pr/create.rb
dude-cli-2.1.0.alpha2 lib/dude/commands/pr/create.rb
dude-cli-2.1.0.alpha1 lib/dude/commands/pr/create.rb