Sha256: 785193350bd8921375e6c613a5f95fc8144dc10d81ef88a3aac986c4f76cb8de

Contents?: true

Size: 1.49 KB

Versions: 150

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require 'avm/result'

module Avm
  module Git
    module Issue
      class Complete
        module LocalBranch
          NO_CURRENT_BRANCH_NAME = 'none'

          # Retrieves the current local branch.
          #
          # @return [EacGit::Local::Branch, nil]
          def branch_uncached
            eac_git.current_branch
          end

          def branch_hash_uncached
            branch.if_present(&:current_commit_id)
          end

          def branch_name
            branch.if_present(NO_CURRENT_BRANCH_NAME, &:name)
          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 ? launcher_git.descendant?(branch_hash, remote_master_hash) : true
          end

          def remove_local_branch
            return unless branch

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

Version data entries

150 entries across 150 versions & 3 rubygems

Version Path
avm-git-0.18.0 lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.94.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.17.0 lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.86.5 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.16.0 lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.86.4 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.86.3 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.15.0 lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.86.2 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.84.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.83.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.82.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
avm-git-0.14.0 lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.81.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.80.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/issue/complete/local_branch.rb