Class: Gync::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/gync/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(local_path, remote_path) ⇒ Git

Returns a new instance of Git.



3
4
5
# File 'lib/gync/git.rb', line 3

def initialize(local_path, remote_path)
  @local_path, @remote_path = local_path, remote_path
end

Instance Method Details

#pullObject



7
8
9
10
11
# File 'lib/gync/git.rb', line 7

def pull
  reopen_repo!
  @git.fetch
  @git.merge 'origin/master'
end

#pushObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/gync/git.rb', line 13

def push
  reopen_repo!
  if not changed_files.empty? or not new_files.empty? or not removed_files.empty?
    @git.add    changed_files unless changed_files.empty?
    @git.add    new_files     unless new_files.empty?
    @git.remove removed_files unless removed_files.empty?
    @git.commit commit_msg
    @git.push "origin", "master"
  end
end