Class: Github
- Inherits:
-
Object
show all
- Includes:
- Mem
- Defined in:
- lib/github.rb
Defined Under Namespace
Classes: BranchCache, TreeHelper
Instance Method Summary
collapse
Constructor Details
#initialize(repo, current_branch = 'master') ⇒ Github
Returns a new instance of Github.
7
8
9
10
11
|
# File 'lib/github.rb', line 7
def initialize(repo, current_branch = 'master')
@repo = repo
@current_branch_name = current_branch
@branch = BranchCache.new(repo)
end
|
Instance Method Details
#add(path) ⇒ Object
23
24
25
|
# File 'lib/github.rb', line 23
def add(path)
added_files << path
end
|
#branch(name) ⇒ Object
13
14
15
16
|
# File 'lib/github.rb', line 13
def branch(name)
current_branch = @branch.read(@current_branch_name)
@branch.create(name, current_branch[:object][:sha])
end
|
#checkout(branch) ⇒ Object
18
19
20
21
|
# File 'lib/github.rb', line 18
def checkout(branch)
@current_branch_name = branch
@branch.read(@current_branch_name)
end
|
#commit(message) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/github.rb', line 27
def commit(message)
current_branch = @branch.read(@current_branch_name)
tree = create_tree(current_branch[:object][:sha])
new_commit = client.create_commit(@repo, message, tree[:sha], current_branch[:object][:sha])
@branch.update(@current_branch_name, new_commit[:sha])
added_files.clear
new_commit
end
|
#pull_request(base, title, body) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/github.rb', line 39
def pull_request(base, title, body)
client.create_pull_request(
@repo,
base,
@current_branch_name,
title,
body
)
end
|