Class: Git::Lib
- Inherits:
-
Object
- Object
- Git::Lib
- Defined in:
- lib/coral_core/util/git/lib.rb
Instance Method Summary collapse
-
#add(path = '.', opts = {}) ⇒ Object
—————————————————————————– Commit extensions.
-
#commit(message, opts = {}) ⇒ Object
—.
-
#escape(s) ⇒ Object
—————————————————————————– Utilities.
-
#remote_add(name, url, opts = {}) ⇒ Object
—————————————————————————– Remote extensions.
-
#remote_remove(name) ⇒ Object
—.
-
#remote_set_url(name, url, opts = {}) ⇒ Object
—.
Instance Method Details
#add(path = '.', opts = {}) ⇒ Object
Commit extensions
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/coral_core/util/git/lib.rb', line 8 def add(path = '.', opts = {}) arr_opts = [] arr_opts << '-u' if opts[:update] if path.is_a?(Array) arr_opts += path else arr_opts << path end command('add', arr_opts) end |
#commit(message, opts = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/coral_core/util/git/lib.rb', line 21 def commit(, opts = {}) arr_opts = ['-m', ] arr_opts << "--author=\'#{opts[:author]}\'" unless opts[:author] && opts[:author].empty? arr_opts << '-a' if opts[:add_all] arr_opts << '--allow-empty' if opts[:allow_empty] command('commit', arr_opts) end |
#escape(s) ⇒ Object
Utilities
73 74 75 76 77 78 79 80 |
# File 'lib/coral_core/util/git/lib.rb', line 73 def escape(s) escaped = s.to_s.gsub('"', '\'') if escaped =~ /^\-+/ escaped else %Q{"#{escaped}"} end end |
#remote_add(name, url, opts = {}) ⇒ Object
Remote extensions
32 33 34 35 36 37 38 39 |
# File 'lib/coral_core/util/git/lib.rb', line 32 def remote_add(name, url, opts = {}) arr_opts = ['add'] arr_opts << '-f' if opts[:with_fetch] arr_opts << name arr_opts << url command('remote', arr_opts) end |
#remote_remove(name) ⇒ Object
66 67 68 |
# File 'lib/coral_core/util/git/lib.rb', line 66 def remote_remove(name) command('remote', ['rm', name]) end |
#remote_set_url(name, url, opts = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/coral_core/util/git/lib.rb', line 43 def remote_set_url(name, url, opts = {}) arr_opts = ['set-url'] if opts[:add] arr_opts << '--add' if opts[:add] end if opts[:delete] arr_opts << '--delete' if opts[:delete] end if opts[:push] arr_opts << '--push' if opts[:push] end arr_opts << name arr_opts << url command('remote', arr_opts) end |