Class: Aerial::Git

Inherits:
Object show all
Defined in:
lib/aerial/base.rb

Overview

Provides a few methods for interacting with that Aerial repository

Class Method Summary collapse

Class Method Details

.commit(path, message) ⇒ Object

Added the file in the path and commit the changs to the repo

+path+ to the new file to commit
+message+ description of the commit


129
130
131
132
133
134
# File 'lib/aerial/base.rb', line 129

def self.commit(path, message)
  Dir.chdir(File.expand_path(Aerial.repo.working_dir)) do
    Aerial.repo.add(path)
  end
  Aerial.repo.commit_index(message)
end

.commit_all(path = ".", message = "Commited all changes at: #{DateTime.now}") ⇒ Object

Adds all untracked files and commits them to the repo



137
138
139
140
141
142
# File 'lib/aerial/base.rb', line 137

def self.commit_all(path = ".", message = "Commited all changes at: #{DateTime.now}")
  unless Aerial.repo.status.untracked.empty?
    self.commit(path, message)
  end
  true
end

.commit_and_push(path, message) ⇒ Object

Commit the new file and push it to the remote repository



121
122
123
124
# File 'lib/aerial/base.rb', line 121

def self.commit_and_push(path, message)
  self.commit(path, message)
  self.push
end

.pushObject

Upload all new commits to the remote repo (if exists)



145
146
147
148
149
150
151
152
153
154
# File 'lib/aerial/base.rb', line 145

def self.push
  return unless Aerial.config.git.name && Aerial.config.git.branch

  begin
    cmd = "push #{Aerial.config.git.name} #{Aerial.config.git.branch} "
    Aerial.repo.git.run('', cmd, '', {}, "")
  rescue Exception => e
    Aerial.log(e.message)
  end
end