class Github::TreeHelper
Public Class Methods
new(repo, branch_sha)
click to toggle source
# File lib/github.rb, line 104 def initialize(repo, branch_sha) @repo = repo @branch_sha = branch_sha end
Public Instance Methods
add(path)
click to toggle source
# File lib/github.rb, line 109 def add(path) content = Base64.encode64(File.read(path)) sha = client.create_blob(@repo, content, 'base64') tree << { path: path, mode: '100644', type: 'blob', sha: sha } end
create_tree()
click to toggle source
# File lib/github.rb, line 115 def create_tree client.create_tree(@repo, tree, base_tree: current_tree[:sha]) end
Private Instance Methods
client()
click to toggle source
# File lib/github.rb, line 132 def client ::Octokit::Client.new end
current_tree()
click to toggle source
# File lib/github.rb, line 121 def current_tree commit = client.commit(@repo, @branch_sha) client.tree(@repo, commit[:commit][:tree][:sha], recursive: true) end
tree()
click to toggle source
# File lib/github.rb, line 127 def tree [] end