Sha256: b791dcc3124cf45c447b9cd17930a3dbb9ecf64a9c17999d2cef850f19c8d50d

Contents?: true

Size: 1.18 KB

Versions: 32

Compression:

Stored size: 1.18 KB

Contents

require 'kameleon/utils'
require 'kameleon/step'

module Kameleon

  class Repository
    def self.check_git_binary
      git_path ||= Utils.which("git")
      if git_path.nil? then
        raise KameleonError, "git binary not found, make sure it is in your current PATH"
      end
    end

    def self.add(name, url, kwargs = {})
      check_git_binary
      cmd = ["git", "clone"]
      if kwargs[:branch]
        cmd.push("-b", kwargs[:branch])
      end
      cmd.push("--", url, File.join(Kameleon.env.repositories_path, name))
      process = ChildProcess.build(*cmd)
      process.io.inherit!
      process.start
      process.wait
      process.stop
    end

    def self.update(name)
      check_git_binary
      git_repo = File.join(Kameleon.env.repositories_path, name)
      cmd = ["git", "--git-dir", File.join(git_repo, ".git"), "--work-tree",
             git_repo, "pull", "--verbose"]
      process = ChildProcess.build(*cmd)
      process.io.inherit!
      process.start
      process.wait
      process.stop
    end

    def self.list
      Dir["#{Kameleon.env.repositories_path}/*"].each do |repo_path|
        Kameleon.ui.info File.basename("#{repo_path}")
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
kameleon-builder-2.10.1 lib/kameleon/repository.rb
kameleon-builder-2.9.4 lib/kameleon/repository.rb
kameleon-builder-2.9.2 lib/kameleon/repository.rb
kameleon-builder-2.9.1 lib/kameleon/repository.rb
kameleon-builder-2.9.0 lib/kameleon/repository.rb
kameleon-builder-2.8.3 lib/kameleon/repository.rb
kameleon-builder-2.8.2 lib/kameleon/repository.rb
kameleon-builder-2.8.1 lib/kameleon/repository.rb
kameleon-builder-2.7.8 lib/kameleon/repository.rb
kameleon-builder-2.7.7 lib/kameleon/repository.rb
kameleon-builder-2.7.6 lib/kameleon/repository.rb
kameleon-builder-2.7.5 lib/kameleon/repository.rb
kameleon-builder-2.7.4 lib/kameleon/repository.rb
kameleon-builder-2.7.3 lib/kameleon/repository.rb
kameleon-builder-2.7.2 lib/kameleon/repository.rb
kameleon-builder-2.7.1 lib/kameleon/repository.rb
kameleon-builder-2.7.0 lib/kameleon/repository.rb
kameleon-builder-2.6.7 lib/kameleon/repository.rb
kameleon-builder-2.6.6 lib/kameleon/repository.rb
kameleon-builder-2.6.5 lib/kameleon/repository.rb