Sha256: eca02ce120b91b98b59a292f300078069c99d0f2da499c464d26851dc32a8d8f

Contents?: true

Size: 1.24 KB

Versions: 26

Compression:

Stored size: 1.24 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 || no_validate_branch
          )
        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

26 entries across 26 versions & 1 rubygems

Version Path
avm-tools-0.33.1 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.33.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.32.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.31.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.30.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.28.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.27.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.26.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.25.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.24.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.23.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.22.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.21.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.20.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.19.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.18.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.17.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.16.0 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.15.1 lib/avm/git/issue/complete/_local_branch.rb
avm-tools-0.15.0 lib/avm/git/issue/complete/_local_branch.rb