module Bimble::Helpers::Github
Constants
- GITHUB_REPO_REGEX
Public Instance Methods
add_blob_to_tree(sha, filename)
click to toggle source
# File lib/bimble/helpers/github.rb, line 67 def add_blob_to_tree(sha, filename) tree = tree default_branch new_tree = github.git_data.trees.create user, repo, "base_tree" => tree['sha'], "tree" => [ "path" => filename, "mode" => "100644", "type" => "blob", "sha" => sha ] new_tree['sha'] end
blob_content(sha)
click to toggle source
# File lib/bimble/helpers/github.rb, line 51 def blob_content(sha) blob = github.git_data.blobs.get user, repo, sha if blob['encoding'] == 'base64' Base64.decode64(blob['content']) else blob['content'] end end
blob_shas(branch, path)
click to toggle source
# File lib/bimble/helpers/github.rb, line 45 def blob_shas(branch, path) tree = tree branch Hash[tree['tree'].select{|x| x['path'] =~ /^#{path}$/ && x['type'] == 'blob'}.map{|x| [x.path, x.sha]}] end
commit(sha)
click to toggle source
# File lib/bimble/helpers/github.rb, line 78 def commit(sha) parent = latest_commit(default_branch) commit = github.git_data.commits.create user, repo, "message" => commit_message, "parents" => [parent], "tree" => sha commit['sha'] end
create_blob(content)
click to toggle source
# File lib/bimble/helpers/github.rb, line 62 def create_blob(content) blob = github.git_data.blobs.create user, repo, "content" => content, "encoding" => "utf-8" blob['sha'] end
create_branch(name, sha)
click to toggle source
# File lib/bimble/helpers/github.rb, line 86 def create_branch(name, sha) branch = github.git_data.references.create user, repo, "ref" => "refs/heads/#{name}", "sha" => sha branch['ref'] end
default_branch()
click to toggle source
# File lib/bimble/helpers/github.rb, line 28 def default_branch repository = github.repos.get user, repo repository.default_branch end
github()
click to toggle source
# File lib/bimble/helpers/github.rb, line 11 def github Github.new oauth_token: @oauth_token end
latest_commit(branch_name)
click to toggle source
# File lib/bimble/helpers/github.rb, line 34 def latest_commit(branch_name) branch_data = github.repos.branch user, repo, branch_name branch_data['commit']['sha'] end
open_pr(head, base)
click to toggle source
# File lib/bimble/helpers/github.rb, line 91 def open_pr(head, base) github.pull_requests.create user, repo, "title" => pull_request_title, "body" => pull_request_body, "head" => head, "base" => base end
repo()
click to toggle source
# File lib/bimble/helpers/github.rb, line 22 def repo match = @git_url.match GITHUB_REPO_REGEX match ? match[2] : nil end
tree(branch)
click to toggle source
# File lib/bimble/helpers/github.rb, line 40 def tree(branch) github.git_data.trees.get user, repo, branch end
user()
click to toggle source
# File lib/bimble/helpers/github.rb, line 16 def user match = @git_url.match GITHUB_REPO_REGEX match ? match[1] : nil end