Sha256: 777c00500e7b6eedf145ac5a56fe5d24cd37cbb0d543af786e4a96d39b7d6a63

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'avm/core_ext'
require 'clipboard'

module Avm
  module Git
    module Issue
      class Deliver
        enable_simple_cache
        enable_speaker

        common_constructor :git_repo

        def run
          push
          clipboard_copy_tracker_message
          true
        end

        def start_banner
          infov 'Branch name', branch_name
          infov 'Commit ID', branch_commit_id
          infov 'Push arguments', ::Shellwords.join(push_args)
        end

        private

        def branch_commit_id
          git_repo.rev_parse(branch_name)
        end

        def branch_name_uncached
          git_repo.command('rev-parse', '--abbrev-ref', 'HEAD').execute!.strip
        end

        def clipboard_copy_tracker_message
          ::Clipboard.copy(textile_tracker_message)
          infov 'Copied to clipboard', textile_tracker_message
        end

        def push
          git_repo.command(*push_args).system!
        end

        def push_args
          %w[push origin --force] + ["#{branch_name}:refs/heads/#{branch_name}"]
        end

        def textile_tracker_message
          "#{branch_name}: commit:#{branch_commit_id}."
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
avm-tools-0.103.0 lib/avm/git/issue/deliver.rb
avm-tools-0.102.2 lib/avm/git/issue/deliver.rb
avm-tools-0.102.1 lib/avm/git/issue/deliver.rb
avm-tools-0.102.0 lib/avm/git/issue/deliver.rb
avm-tools-0.101.0 lib/avm/git/issue/deliver.rb
avm-tools-0.100.0 lib/avm/git/issue/deliver.rb
avm-tools-0.99.1 lib/avm/git/issue/deliver.rb
avm-tools-0.99.0 lib/avm/git/issue/deliver.rb