class Git
Attributes
path[RW]
Public Class Methods
new(path = Dir.pwd)
click to toggle source
# File lib/updater/git.rb, line 4 def initialize(path = Dir.pwd) @path = path end
Public Instance Methods
clone(url, options = '.')
click to toggle source
# File lib/updater/git.rb, line 17 def clone(url, options = '.') execute('git clone', url, options) end
commit(message)
click to toggle source
# File lib/updater/git.rb, line 8 def commit(message) execute('git add', '--all') execute('git commit', '-m', "'#{message}'") end
create_github_repo(access_token, org, name, endpoint)
click to toggle source
# File lib/updater/git.rb, line 25 def create_github_repo(access_token, org, name, endpoint) execute('curl', "#{endpoint}/orgs/#{org}/repos?access_token=#{access_token}", '-d', "'{\"name\":\"#{name}\"}'") end
push(remote = 'origin master', options = nil)
click to toggle source
# File lib/updater/git.rb, line 13 def push(remote = 'origin master', options = nil) execute('git push', remote, options) end
set_origin(url)
click to toggle source
# File lib/updater/git.rb, line 21 def set_origin(url) execute('git remote', 'set-url origin', url) end
Private Instance Methods
execute(*command)
click to toggle source
# File lib/updater/git.rb, line 33 def execute(*command) FileUtils.mkdir_p(path) unless Dir.exists?(path) Dir.chdir(path) do system(*command.join(" ").strip) end end