Sha256: 63a68b88eaf63599bf6a88fe925eac4ca99fe298a31746467a0abfdbba3fdcd4

Contents?: true

Size: 1.65 KB

Versions: 29

Compression:

Stored size: 1.65 KB

Contents

module Git
class Lib

  #-----------------------------------------------------------------------------
  # Commit extensions
  
  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
  
  #---
  
  def commit(message, opts = {})
    arr_opts = ['-m', message]
    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
  
  #-----------------------------------------------------------------------------
  # Remote extensions
  
  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
  
  #---

  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
  
  #---
      
  def remote_remove(name)
    command('remote', ['rm', name])
  end
  
  #-----------------------------------------------------------------------------
  # Utilities
  
  def escape(s)
    escaped = s.to_s.gsub('"', '\'')
    if escaped =~ /^\-+/
      escaped  
    else
      %Q{"#{escaped}"}
    end
  end
end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
coral_core-0.2.25 lib/coral_core/util/git/lib.rb
coral_core-0.2.24 lib/coral_core/util/git/lib.rb
coral_core-0.2.19 lib/coral_core/util/git/lib.rb
coral_core-0.2.18 lib/coral_core/util/git/lib.rb
coral_core-0.2.17 lib/coral_core/util/git/lib.rb
coral_core-0.2.16 lib/coral_core/util/git/lib.rb
coral_core-0.2.15 lib/coral_core/util/git/lib.rb
coral_core-0.2.14 lib/coral_core/util/git/lib.rb
coral_core-0.2.13 lib/coral_core/util/git/lib.rb
coral_core-0.2.12 lib/coral_core/util/git/lib.rb
coral_core-0.2.11 lib/coral_core/util/git/lib.rb
coral_core-0.2.10 lib/coral_core/util/git/lib.rb
coral_core-0.2.9 lib/coral_core/util/git/lib.rb
coral_core-0.2.8 lib/coral_core/util/git/lib.rb
coral_core-0.2.7 lib/coral_core/util/git/lib.rb
coral_core-0.2.6 lib/coral_core/util/git/lib.rb
coral_core-0.2.5 lib/coral_core/util/git/lib.rb
coral_core-0.2.4 lib/coral_core/util/git/lib.rb
coral_core-0.2.3 lib/coral_core/util/git/lib.rb
coral_core-0.2.2 lib/coral_core/util/git/lib.rb