Module: Gpr::GitHelper
- Defined in:
- lib/gpr/git_helper.rb
Class Method Summary collapse
- .clone(url, path) ⇒ Object
- .fetch(path, remote, branch) ⇒ Object
- .ls_files(path) ⇒ Object
- .status(path) ⇒ Object
Class Method Details
.clone(url, path) ⇒ Object
4 5 6 |
# File 'lib/gpr/git_helper.rb', line 4 def clone(url, path) system("git clone #{url} #{path} >/dev/null 2>&1") end |
.fetch(path, remote, branch) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/gpr/git_helper.rb', line 13 def fetch(path, remote, branch) Dir.chdir(path) if branch.nil? `git fetch #{remote}` else `git fetch #{remote} #{branch}` end end |
.ls_files(path) ⇒ Object
8 9 10 11 |
# File 'lib/gpr/git_helper.rb', line 8 def ls_files(path) Dir.chdir(path) `git ls-files`.split("\n") end |
.status(path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gpr/git_helper.rb', line 22 def status(path) Dir.chdir(path) result = {} status = `git status` result[:branch] = status.match(/Your branch (is|and) (.+?)(,|\.)/)[2] case status when /nothing to commit, working directory clean/ result[:directory] = 'Working directory clean' when /Changes not staged for commit:/ result[:directory] = 'Exist unstaged changes' when /Untracked files:/ result[:directory] = 'Exist untracked files' end result end |