Sha256: 93c63e9ea2d0f68ae2a288a2a7efd94fb60289aa2a975ccdfe118c7eb6811dfc

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

module LocalPac
  class Git
    def self.ls_files(filter = nil)
      cmd = ['git ls-files']
      cmd << " #{filter}" if filter

      runner = Runner.new(cmd.join(" "))
      runner.result
    end

    def self.ls_tree(git_dir = nil)
      cmd = ['git']
      cmd << "--git-dir #{git_dir}" if git_dir
      cmd << 'ls-tree -r HEAD'

      runner = Runner.new(cmd.join(" "))
      runner.result
    end

    def self.init(path, is_bare = false)
      cmd = ["git init #{path}"]
      cmd << "--bare" if is_bare

      runner = Runner.new(cmd.join(" "))
      runner.result
    end

    def self.add(object)
      runner = Runner.new("git add #{object}")
      runner.result
    end

    def self.commit(message)
      runner = Runner.new("git commit -m \"#{message}\"")
      runner.result
    end

    def self.status
      runner = Runner.new('git status')
      runner.result
    end

    def self.show(sha = nil, git_dir = nil)
      cmd = ['git']
      cmd << "--git-dir #{git_dir}" if git_dir
      cmd << 'show'
      cmd << " #{sha}" if sha

      runner = Runner.new(cmd.join(" "))
      runner.result
    end

    def self.cat_file(sha, git_dir = nil)
      cmd = ['git']
      cmd << "--git-dir #{git_dir}" if git_dir
      cmd << 'cat-file -p'
      cmd << sha

      runner = Runner.new(cmd.join(" "))
      runner.result
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
local_pac-0.1.10 lib/local_pac/git.rb
local_pac-0.1.9 lib/local_pac/git.rb
local_pac-0.1.8 lib/local_pac/git.rb
local_pac-0.1.7 lib/local_pac/git.rb
local_pac-0.1.6 lib/local_pac/git.rb
local_pac-0.1.5 lib/local_pac/git.rb
local_pac-0.1.4 lib/local_pac/git.rb
local_pac-0.1.3 lib/local_pac/git.rb
local_pac-0.1.2 lib/local_pac/git.rb
local_pac-0.1.1 lib/local_pac/git.rb
local_pac-0.1.0 lib/local_pac/git.rb