Class: Crackin::Scm::Git
Direct Known Subclasses
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
Instance Method Summary collapse
- #add(options = {}) ⇒ Object
- #between(from, to) ⇒ Object
- #change_branch(to) ⇒ Object
- #commit(message) ⇒ Object
- #create_branch(name) ⇒ Object
- #current_branch ⇒ Object
- #delete_branch(name) ⇒ Object
-
#initialize(config = {}) ⇒ Git
constructor
A new instance of Git.
- #log ⇒ Object
- #merge_from(from) ⇒ Object
- #pending ⇒ Object
- #pending? ⇒ Boolean
- #pull ⇒ Object
- #push(remote = @git.remote, branch = current_branch) ⇒ Object
- #push_tags(remote = @git.remote, branch = current_branch) ⇒ Object
- #reset ⇒ Object
- #tags ⇒ Object
- #uncommit ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(config = {}) ⇒ Git
Returns a new instance of Git.
8 9 10 11 12 13 14 |
# File 'lib/crackin/scm/git.rb', line 8 def initialize(config={}) super #@git = ::Git.open(@options[:working], log: Logger.new(STDOUT)) o = {} o['log'] = Logger.new(STDOUT) if config['debug'] @git = ::Git.open(@options[:working], o.deep_symbolize_keys) end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
7 8 9 |
# File 'lib/crackin/scm/git.rb', line 7 def git @git end |
Instance Method Details
#add(options = {}) ⇒ Object
16 17 18 |
# File 'lib/crackin/scm/git.rb', line 16 def add(={}) @git.add() end |
#between(from, to) ⇒ Object
24 25 26 |
# File 'lib/crackin/scm/git.rb', line 24 def between(from, to) @git.log.between(from, to) end |
#change_branch(to) ⇒ Object
57 58 59 |
# File 'lib/crackin/scm/git.rb', line 57 def change_branch(to) @git.checkout(to) end |
#commit(message) ⇒ Object
32 33 34 |
# File 'lib/crackin/scm/git.rb', line 32 def commit() @git.commit_all() end |
#create_branch(name) ⇒ Object
61 62 63 64 65 |
# File 'lib/crackin/scm/git.rb', line 61 def create_branch(name) branch = @git.branch(Shellwords.escape(name)) branch.create branch.checkout end |
#current_branch ⇒ Object
53 54 55 |
# File 'lib/crackin/scm/git.rb', line 53 def current_branch @git.branch_current end |
#delete_branch(name) ⇒ Object
67 68 69 70 |
# File 'lib/crackin/scm/git.rb', line 67 def delete_branch(name) @git.checkout @git.branch(Shellwords.escape(name)).delete end |
#log ⇒ Object
20 21 22 |
# File 'lib/crackin/scm/git.rb', line 20 def log @git.log end |
#merge_from(from) ⇒ Object
49 50 51 |
# File 'lib/crackin/scm/git.rb', line 49 def merge_from(from) @git.branch(from).merge end |
#pending ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/crackin/scm/git.rb', line 84 def pending s = @git.status d = {} d.merge! s.changed d.merge! s.added d.merge! s.deleted d.merge! s.untracked d end |
#pending? ⇒ Boolean
94 95 96 |
# File 'lib/crackin/scm/git.rb', line 94 def pending? pending.count > 0 end |
#pull ⇒ Object
72 73 74 |
# File 'lib/crackin/scm/git.rb', line 72 def pull @git.pull end |
#push(remote = @git.remote, branch = current_branch) ⇒ Object
76 77 78 |
# File 'lib/crackin/scm/git.rb', line 76 def push(remote=@git.remote, branch=current_branch) @git.push(remote, branch) end |
#push_tags(remote = @git.remote, branch = current_branch) ⇒ Object
80 81 82 |
# File 'lib/crackin/scm/git.rb', line 80 def (remote=@git.remote, branch=current_branch) @git.push(remote, branch, true) end |
#reset ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/crackin/scm/git.rb', line 40 def reset @git.checkout_file('--', '.') @git.clean(d: true, force: true) #pending.keys.each do |p| # puts "pending: #{p}" # @git.checkout_file('--', p) #end end |
#uncommit ⇒ Object
36 37 38 |
# File 'lib/crackin/scm/git.rb', line 36 def uncommit @git.reset_hard('HEAD^') end |