Sha256: b2d09add7d64e62206e066b284c17631a65d31cdfdb8c57058407e1dfb4b2800

Contents?: true

Size: 595 Bytes

Versions: 16

Compression:

Stored size: 595 Bytes

Contents

require 'dply/git'
module Dply
  class Repo

    attr_reader :dir, :upstream, :mirror

    def initialize(dir, upstream, mirror: nil)
      @dir = dir
      @upstream = upstream
      @mirror = mirror
    end

    def create
      if Dir.exist? "#{dir}/.git"
        raise Error, "unable to create repo (another repo already exists)" if not verify_remote_url
      else
        Git.clone upstream, dir, mirror: @mirror
      end
    end

    private

    def verify_remote_url
      remote_url = Dir.chdir(dir) do
        Git.remote_url
      end
      remote_url == upstream
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/repo.rb
dply-0.3.14 lib/dply/repo.rb
dply-0.3.13 lib/dply/repo.rb
dply-0.3.12 lib/dply/repo.rb
dply-0.3.11 lib/dply/repo.rb
dply-0.3.10 lib/dply/repo.rb
dply-0.3.9 lib/dply/repo.rb
dply-0.3.8 lib/dply/repo.rb
dply-0.3.7 lib/dply/repo.rb
dply-0.3.6 lib/dply/repo.rb
dply-0.3.5 lib/dply/repo.rb
dply-0.3.4 lib/dply/repo.rb
dply-0.3.3 lib/dply/repo.rb
dply-0.3.2 lib/dply/repo.rb
dply-0.3.1 lib/dply/repo.rb
dply-0.3.0 lib/dply/repo.rb