Module: VimPK::Git
- Defined in:
- lib/vimpk/git.rb
Defined Under Namespace
Classes: GitError
Class Method Summary collapse
- .branch(dir: Dir.pwd) ⇒ Object
- .clone(source, dest, dir: Dir.pwd) ⇒ Object
- .command(args, dir: Dir.pwd) ⇒ Object
- .fetch(branch, dir: Dir.pwd) ⇒ Object
- .log(branch, dir: Dir.pwd) ⇒ Object
- .pull(dir: Dir.pwd) ⇒ Object
Class Method Details
.branch(dir: Dir.pwd) ⇒ Object
14 15 16 |
# File 'lib/vimpk/git.rb', line 14 def branch(dir: Dir.pwd) command("rev-parse --abbrev-ref HEAD", dir: dir) end |
.clone(source, dest, dir: Dir.pwd) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/vimpk/git.rb', line 30 def clone(source, dest, dir: Dir.pwd) out = command("clone #{source} #{dest}", dir: dir) if $?.exitstatus != 0 raise GitError.new("Failed to clone #{source} to #{dest}", out) end end |
.command(args, dir: Dir.pwd) ⇒ Object
37 38 39 40 41 |
# File 'lib/vimpk/git.rb', line 37 def command(args, dir: Dir.pwd) IO.popen("git -C #{dir} #{args}", dir: dir, err: [:child, :out]) do |io| io.read.chomp end end |
.fetch(branch, dir: Dir.pwd) ⇒ Object
22 23 24 |
# File 'lib/vimpk/git.rb', line 22 def fetch(branch, dir: Dir.pwd) command("fetch origin #{branch}", dir: dir) end |
.log(branch, dir: Dir.pwd) ⇒ Object
18 19 20 |
# File 'lib/vimpk/git.rb', line 18 def log(branch, dir: Dir.pwd) command("log -p --full-diff HEAD..origin/#{branch}", dir: dir) end |
.pull(dir: Dir.pwd) ⇒ Object
26 27 28 |
# File 'lib/vimpk/git.rb', line 26 def pull(dir: Dir.pwd) command("pull --rebase", dir: dir) end |