Sha256: 2861c1bd1a0cf849f1287a3d032dbc3e431f7785a6e821ee1f01481eb09d5827

Contents?: true

Size: 1.32 KB

Versions: 75

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Avm
  module Git
    module Issue
      class Complete
        def dry_push_args
          %w[push --dry-run] + [remote_name] + pushs
        end

        def dry_push_result
          return ::Avm::Result.error('Nothing to push') if pushs.empty?

          r = @git.execute(dry_push_args)
          message = if r.fetch(:exit_code).zero?
                      'ok'
                    else
                      r.fetch(:stderr) + "\n#{::Shellwords.join(dry_push_args)}"
                    end
          ::Avm::Result.success_or_error(r.fetch(:exit_code).zero?, message)
        end

        def push
          if pushs.empty?
            info 'PUSH: Nada a enviar'
          else
            info "PUSH: enviando \"#{pushs}\"..."
            git(%w[push origin] + pushs)
          end
        end

        def pushs_uncached
          [master_push, remove_branch_push, tag_push].reject(&:nil?)
        end

        def master_push
          remote_master_hash != branch_hash ? "#{branch_hash}:refs/heads/master" : nil
        end

        def remove_branch_push
          remote_branch_hash ? ":refs/heads/#{branch}" : nil
        end

        def tag_push
          return nil unless !remote_tag_hash || remote_tag_hash != branch_hash

          "#{branch_hash}:#{tag}"
        end
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
avm-tools-0.102.1 lib/avm/git/issue/complete/_push.rb
avm-tools-0.102.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.101.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.100.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.99.1 lib/avm/git/issue/complete/_push.rb
avm-tools-0.99.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.98.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.97.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.96.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.95.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.94.3 lib/avm/git/issue/complete/_push.rb
avm-tools-0.94.2 lib/avm/git/issue/complete/_push.rb
avm-tools-0.94.1 lib/avm/git/issue/complete/_push.rb
avm-tools-0.94.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.93.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.92.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.91.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.90.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.89.0 lib/avm/git/issue/complete/_push.rb
avm-tools-0.88.0 lib/avm/git/issue/complete/_push.rb