Class: Git
- Inherits:
-
Object
- Object
- Git
- Defined in:
- lib/updater/git.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #clone(url:, options: '.') ⇒ Object
- #commit(message:) ⇒ Object
- #create_github_repo(access_token:, org:, name:, endpoint:) ⇒ Object
-
#initialize(path: Dir.pwd) ⇒ Git
constructor
A new instance of Git.
- #push(remote: 'origin master', options: nil) ⇒ Object
- #set_origin(url:) ⇒ Object
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
#path ⇒ Object
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, ) 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, ) 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 |