Sha256: 0495b87394a6ee5317690099c5bf721af895ecf1cf779c25dea34b89376d438b

Contents?: true

Size: 1.25 KB

Versions: 23

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'avm/result'

module Avm
  module Git
    module Issue
      class Complete
        module LocalBranch
          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(issue_id.present?, branch_name)
          end

          def branch_hash_result
            ::Avm::Result.success_or_error(
              branch_hash.present?,
              branch_hash
            )
          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')
          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
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
avm-tools-0.113.5 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.113.4 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.113.3 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.113.2 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.3.0 lib/avm/git/issue/complete/local_branch.rb
avm-git-0.2.0 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.110.0 vendor/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.109.1 vendor/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.1.0 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.109.0 vendor/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-0.5.0 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.108.0 vendor/avm/lib/avm/git/issue/complete/local_branch.rb
avm-0.4.0 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.107.0 vendor/avm/lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.106.0 vendor/avm/lib/avm/git/issue/complete/local_branch.rb
avm-0.3.2 lib/avm/git/issue/complete/local_branch.rb
avm-0.3.1 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.105.0 vendor/avm/lib/avm/git/issue/complete/local_branch.rb
avm-0.3.0 lib/avm/git/issue/complete/local_branch.rb
avm-tools-0.104.0 vendor/avm/lib/avm/git/issue/complete/local_branch.rb