Class: Git

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: Dir.pwd) ⇒ Git

Returns a new instance of Git.



4
5
6
# File 'lib/updater/git.rb', line 4

def initialize(path: Dir.pwd)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/updater/git.rb', line 2

def path
  @path
end

Instance Method Details

#clone(url:, options: '.') ⇒ Object



17
18
19
# File 'lib/updater/git.rb', line 17

def clone(url:, options: '.')
  execute('git clone', url, options)
end

#commit(message:) ⇒ Object



8
9
10
11
# 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:) ⇒ Object



25
26
27
28
29
# 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) ⇒ Object



13
14
15
# File 'lib/updater/git.rb', line 13

def push(remote: 'origin master', options: nil)
  execute('git push', remote, options)
end

#set_origin(url:) ⇒ Object



21
22
23
# File 'lib/updater/git.rb', line 21

def set_origin(url:)
  execute('git remote', 'set-url origin', url)
end