Module: GitWand::GitHub::API::Commands::Branch
- Included in:
- GitWand::GitHub::API::Client
- Defined in:
- lib/git_wand/github/api/commands/branch.rb
Instance Method Summary collapse
- #create_branch(owner:, repo:, dest_branch:, source_branch:) ⇒ Object
-
#delete_branch(owner:, repo:, branch:) ⇒ Object
Delete a Reference developer.github.com/v3/git/refs/#delete-a-reference Example: Deleting a branch: DELETE /repos/octocat/Hello-World/git/refs/heads/feature-a.
-
#get_branch(owner:, repo:, branch:) ⇒ Object
Get Branch developer.github.com/v3/repos/branches/#get-branch GET /repos/:owner/:repo/branches/:branch.
Instance Method Details
#create_branch(owner:, repo:, dest_branch:, source_branch:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/git_wand/github/api/commands/branch.rb', line 20 def create_branch(owner:, repo:, dest_branch:, source_branch:) result = get_branch(owner: owner, repo: repo, branch: source_branch) branch = result.resource # TODO: handle errors while retrieving the resource parameters = { ref: "refs/heads/#{dest_branch}", sha: branch.commit["sha"] } response = post(resource: "repos/#{owner}/#{repo}/git/refs", parameters: parameters) result = Result.new result.success = response[:status][:code] == "201" result.body = response[:body] result end |
#delete_branch(owner:, repo:, branch:) ⇒ Object
Delete a Reference developer.github.com/v3/git/refs/#delete-a-reference Example: Deleting a branch: DELETE /repos/octocat/Hello-World/git/refs/heads/feature-a
39 40 41 42 43 44 45 |
# File 'lib/git_wand/github/api/commands/branch.rb', line 39 def delete_branch(owner:, repo:, branch:) response = delete(resource: "repos/#{owner}/#{repo}/git/refs/heads/#{branch}") result = Result.new result.success = response[:status][:code] == "204" result.body = response[:body] result end |
#get_branch(owner:, repo:, branch:) ⇒ Object
Get Branch developer.github.com/v3/repos/branches/#get-branch GET /repos/:owner/:repo/branches/:branch
11 12 13 14 15 16 17 18 |
# File 'lib/git_wand/github/api/commands/branch.rb', line 11 def get_branch(owner:, repo:, branch:) response = get(resource: "repos/#{owner}/#{repo}/branches/#{branch}") result = Result.new result.success = response[:status][:code] == "200" result.body = response[:body] result.resource = Resource::Branch.build_from_api_result(result) result end |