Sha256: 46cfd06d7d751c8f9bb66561adcdc8dc3e63e2db2910f9b9779ccf8ecf1d18c0

Contents?: true

Size: 748 Bytes

Versions: 4

Compression:

Stored size: 748 Bytes

Contents

require "rugged"

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

4 entries across 4 versions & 1 rubygems

Version Path
rfix-1.1.0.pre.150 lib/rfix/branches/main.rb
rfix-1.1.1.pre lib/rfix/branches/main.rb
rfix-1.1.0.pre.149 lib/rfix/branches/main.rb
rfix-1.1.0.pre.147 lib/rfix/branches/main.rb