Module: Avm::Git::Issue::Complete::Push

Defined in:
lib/avm/git/issue/complete/push.rb

Instance Method Summary collapse

Instance Method Details

#dry_push_argsObject



8
9
10
# File 'lib/avm/git/issue/complete/push.rb', line 8

def dry_push_args
  %w[push --dry-run] + [remote_name] + pushs
end

#dry_push_resultObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/avm/git/issue/complete/push.rb', line 12

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

#master_pushObject



37
38
39
# File 'lib/avm/git/issue/complete/push.rb', line 37

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

#pushObject



24
25
26
27
28
29
30
31
# File 'lib/avm/git/issue/complete/push.rb', line 24

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

#pushs_uncachedObject



33
34
35
# File 'lib/avm/git/issue/complete/push.rb', line 33

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

#remove_branch_pushObject



41
42
43
# File 'lib/avm/git/issue/complete/push.rb', line 41

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

#tag_pushObject



45
46
47
48
49
# File 'lib/avm/git/issue/complete/push.rb', line 45

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

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