Sha256: d19ade8988d0b60906f4a672db7c5247d169e6b2a4235791df0f25004cc44af2

Contents?: true

Size: 593 Bytes

Versions: 3

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

require 'fileutils'

module LearnTest
  module Git
    module Wip
      class Reference < Branch
        attr_accessor :parent

        PREFIX = 'refs/wip/'

        def initialize(base:, name:)
          dir = File.join(base.repo.path, PREFIX)
          file = File.join(dir, name)
          sha = base.log(1)[0].sha

          FileUtils.mkdir_p(dir, { mode: 0755 }) unless Dir.exist?(dir)
          File.open(file, 'w+') { |f| f.puts sha } unless File.exist?(file)

          super(base: base, name: "#{PREFIX}#{name}")
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
learn-test-3.3.1 lib/learn_test/git/wip/reference.rb
learn-test-3.3.0 lib/learn_test/git/wip/reference.rb
learn-test-3.3.0.pre.6 lib/learn_test/git/wip/reference.rb