Class: ProjMgr::Git
Overview
A wrapper class for interacting with a git repository
Instance Attribute Summary
Attributes inherited from Scm
Instance Method Summary collapse
-
#has_local_changes? ⇒ Boolean
Checks for local changes in the target repository.
-
#update ⇒ String
Checks for updates in the target repository.
Methods inherited from Scm
#initialize, #inspect, #path_exists?, #project_parent_directory
Constructor Details
This class inherits a constructor from ProjMgr::Scm
Instance Method Details
#has_local_changes? ⇒ Boolean
Checks for local changes in the target repository
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/projmgr/git.rb', line 50 def has_local_changes? if path_exists? == false return false, "path does not exists, please check the path or check it out" else results = `cd #{@path} && git status && cd #{@root}` if results !~ /nothing to commit/ return true, "has local changes" elsif results =~ /Your branch is ahead of/ return true, "has local changes" elsif results =~ /Untracked files/ return true, "has local changes" else return false, "has no local changes" end end end |
#update ⇒ String
Checks for updates in the target repository
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/projmgr/git.rb', line 33 def update if path_exists? == false return "path does not exists, cannot update repository" else results = `cd #{@path} && git pull && cd #{@root}` if results =~ /Already up-to-date./ return "Already up-to-date!" else return results end end end |