class Ruboty::Github::Actions::CreateBranch
Public Instance Methods
call()
click to toggle source
# File lib/ruboty/github/actions/create_branch.rb, line 5 def call if has_access_token? create else require_access_token end end
Private Instance Methods
create()
click to toggle source
# File lib/ruboty/github/actions/create_branch.rb, line 15 def create message.reply("Created #{create_branch._links.html}") rescue Octokit::Unauthorized message.reply("Failed in authentication (401)") rescue Octokit::NotFound message.reply("Could not find that repository") rescue => exception message.reply("Failed by #{exception.class} #{exception}") end
create_branch()
click to toggle source
# File lib/ruboty/github/actions/create_branch.rb, line 25 def create_branch sha = client.branch(from_repo, from_branch).commit.sha client.create_ref(from_repo, "heads/#{to_branch}", sha) client.branch(from_repo, to_branch) end
from()
click to toggle source
e.g. alice/foo:test
# File lib/ruboty/github/actions/create_branch.rb, line 37 def from message[:from] end
from_branch()
click to toggle source
e.g. test
# File lib/ruboty/github/actions/create_branch.rb, line 47 def from_branch from.split(":").last end
from_repo()
click to toggle source
e.g. alice/foo
# File lib/ruboty/github/actions/create_branch.rb, line 42 def from_repo from.split(":").first end
to_branch()
click to toggle source
e.g. new-branch-name
# File lib/ruboty/github/actions/create_branch.rb, line 32 def to_branch message[:to_branch] end