Sha256: 474504716cf99cdb4b5373a76d1148a136af6a7698af030d33262853483a4461

Contents?: true

Size: 1.19 KB

Versions: 22

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'avm/result'

module Avm
  module Git
    module Issue
      class Complete
        def branch_uncached
          @git.current_branch
        end

        def branch_hash_uncached
          @git.rev_parse("refs/heads/#{branch}")
        end

        def branch_name
          branch.split('/')[-1]
        end

        def branch_name_result
          ::Avm::Result.success_or_error(branch_name, issue_id.present?)
        end

        def branch_hash_result
          ::Avm::Result.success_or_error(
            branch_hash,
            branch_hash.present?
          )
        end

        def follow_master_result
          return ::Avm::Result.neutral('No branch hash') unless branch_hash

          r = follow_master?
          ::Avm::Result.success_or_error(
            r ? 'yes' : 'no',
            r
          )
        end

        def follow_master?
          remote_master_hash ? @git.descendant?(branch_hash, remote_master_hash) : true
        end

        def remove_local_branch
          info 'Removendo branch local...'
          bn = branch_name
          git(['checkout', branch_hash])
          git(['branch', '-D', bn])
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
avm-tools-0.52.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.51.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.50.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.49.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.48.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.47.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.46.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.45.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.44.2 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.44.1 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.44.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.43.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.42.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.41.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.40.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.39.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.38.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.37.1 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.37.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.36.0 lib/avm/git/issue/complete/_local_branch.rb