Class: Git
- Inherits:
-
Object
- Object
- Git
- Defined in:
- lib/peas/git.rb
Class Method Summary collapse
- .add_remote(remote) ⇒ Object
- .name_from_remote(remote_uri = nil) ⇒ Object
- .remote(remote = 'peas') ⇒ Object
- .remove_remote(remote = 'peas') ⇒ Object
- .root_path ⇒ Object
- .sh(cmd) ⇒ Object
Class Method Details
.add_remote(remote) ⇒ Object
16 17 18 |
# File 'lib/peas/git.rb', line 16 def self.add_remote(remote) sh "git remote add peas #{remote}" end |
.name_from_remote(remote_uri = nil) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/peas/git.rb', line 24 def self.name_from_remote(remote_uri = nil) remote_uri = remote unless remote_uri exit_now! "No Peas remote. I can't figure out what app this is.", 1 if remote_uri == '' parts = Addressable::URI.parse remote_uri parts.path.split('/').last.gsub('.git', '').downcase end |
.remote(remote = 'peas') ⇒ Object
12 13 14 |
# File 'lib/peas/git.rb', line 12 def self.remote(remote = 'peas') sh "git config --get remote.#{remote}.url" end |
.remove_remote(remote = 'peas') ⇒ Object
20 21 22 |
# File 'lib/peas/git.rb', line 20 def self.remove_remote(remote = 'peas') sh "git remote rm #{remote}" end |
.root_path ⇒ Object
8 9 10 |
# File 'lib/peas/git.rb', line 8 def self.root_path sh 'git rev-parse --show-toplevel' end |
.sh(cmd) ⇒ Object
4 5 6 |
# File 'lib/peas/git.rb', line 4 def self.sh(cmd) `#{cmd}`.strip end |