Sha256: c563c02755d7931af55bd5f44da4fef0a4b8d7e60b04571f59201d0fac5b2786

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

# takelage bit scope add
module BitScopeAdd
  # Backend method for bit scope add.
  def bit_scope_add(scope)
    log.debug "Adding bit remote scope \"#{scope}\" to local workspace"

    return false unless configured? %w[bit_ssh bit_remote]

    return false unless _bit_scope_add_workspace_ready?

    return false unless _bit_scope_add_scope_exists? scope

    run _bit_scope_add_cmd scope

    log.info "Added bit remote scope \"#{scope}\" to local bit workspace"
  end

  private

  # Check if workspace ready for bit scope add.
  def _bit_scope_add_workspace_ready?
    unless bit_check_workspace
      log.error 'No bit workspace'
      return false
    end

    return true unless git_check_workspace

    return true if git_check_bit

    log.error 'Not on git main branch'
    false
  end

  # Check if bit remote scope exists.
  def _bit_scope_add_scope_exists?(scope)
    return true if bit_scope_list.include? scope

    log.error "The bit remote bit scope \"#{scope}\" doesn't exist"
    false
  end

  # Prepare bit add scope command.
  def _bit_scope_add_cmd(scope)
    remote = config.active['bit_remote']

    format(
      config.active['cmd_bit_scope_add_scope'],
      remote: remote,
      scope: scope
    )
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
takelage-0.33.1 lib/takelage/bit/scope/add.rb
takelage-0.32.4 lib/takelage/bit/scope/add.rb
takelage-0.32.3 lib/takelage/bit/scope/add.rb
takelage-0.32.1 lib/takelage/bit/scope/add.rb
takelage-0.32.0 lib/takelage/bit/scope/add.rb
takelage-0.31.0 lib/takelage/bit/scope/add.rb
takelage-0.30.6 lib/takelage/bit/scope/add.rb
takelage-0.30.5 lib/takelage/bit/scope/add.rb
takelage-0.30.1 lib/takelage/bit/scope/add.rb
takelage-0.30.0 lib/takelage/bit/scope/add.rb