Sha256: 3ca54d02641f25c7e000f6e20f4df794daadcb01926b548f10a2e7ecc7ee34a9

Contents?: true

Size: 772 Bytes

Versions: 7

Compression:

Stored size: 772 Bytes

Contents

require "rugged"
require_relative "base"

module Rfix
  class Branch::Main < Branch::Base
    KEY = "rfix.main.branch"

    def resolve(with:)
      unless name = with.config[KEY]
        raise Error.new("Please run {{command:rfix setup}} first")
      end

      String.new(name).resolve(with: with)
    end

    def self.set(branch, at: Dir.pwd)
      unless branch.is_a?(String)
        raise Rfix::Error.new("Branch must be a string, got {{error:#{branch.class}}}")
      end

      check = Branch::Name.new(branch)
      repo = Branch.repo(at: at)
      Branch.repo(at: at).config[KEY] = check.branch(using: repo).name
    end

    def self.get(at: Dir.pwd)
      Branch.repo(at: at).config[KEY]
    end

    def to_s
      "configured main branch"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rfix-1.2.2.pre.174 lib/rfix/branches/main.rb
rfix-1.2.3.pre lib/rfix/branches/main.rb
rfix-1.2.2.pre lib/rfix/branches/main.rb
rfix-1.2.2.pre.172 lib/rfix/branches/main.rb
rfix-1.2.2 lib/rfix/branches/main.rb
rfix-1.2.0 lib/rfix/branches/main.rb
rfix-1.1.4.pre lib/rfix/branches/main.rb