Skip to content

Commit 0fff083

Browse files
committed
docs for merging api
1 parent 2f10ea4 commit 0fff083

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

content/v3/repos/merging.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: Repo Merging | GitHub API
3+
---
4+
5+
# Repo Merging API
6+
7+
The Repo Merging API supports merging branches in a repository. This accomplishes
8+
essentially the same thing as merging one branch into another in a local repository
9+
and then pushing to GitHub. The benefit is that the merge is done on the server side
10+
and a local repository is not needed. This makes it more appropriate for automation
11+
and other tools where maintaining local repositories would be cumbersome and inefficient.
12+
13+
The authenticated user will be the author of any merges done through this endpoint.
14+
15+
## Perform a merge
16+
17+
POST /repos/:user/:repo/merges
18+
19+
### Input
20+
21+
base
22+
: _Required_ **string** - The name of the base branch that the head will be merged into.
23+
24+
head
25+
: _Required_ **string** - The head to merge. This can be a branch name or a commit SHA1.
26+
27+
commit_message
28+
: _Optional_ **string** - Commit message to use for the merge commit.
29+
If omitted, a default message will be used.
30+
31+
<%= json \
32+
:base => "master",
33+
:head => "cool_feature",
34+
:commit_message => "Shipped cool_feature!"
35+
%>
36+
37+
### Successful Response *(The resulting merge commit)*
38+
39+
<%= headers 201 %>
40+
<%= json(:merge_commit) %>
41+
42+
### No-op response (base already contains the head, nothing to merge)
43+
44+
<%= headers 204 %>
45+
46+
### Merge conflict response
47+
48+
<%= headers 409 %>
49+
<%= json({ :message => "Merge Conflict" }) %>
50+
51+
### Missing base or head response
52+
53+
<%= headers 404 %>
54+
<%= json(:message => "Base does not exist") %>
55+
<%= json(:message => "Head does not exist") %>

layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ <h3><a href="#" class="js-expand-btn collapsed">&nbsp;</a><a href="/v3/repos/">R
9696
<li><a href="/v3/repos/keys/">Keys</a></li>
9797
<li><a href="/v3/repos/watching/">Watching</a></li>
9898
<li><a href="/v3/repos/hooks/">Hooks</a></li>
99+
<li><a href="/v3/repos/merging/">Merging</a></li>
99100
</ul>
100101
</li>
101102
<li class="js-topic">

lib/resources.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,49 @@ def text_html(response, status, head = {})
216216
{"html"=>"https://github.com/octocat/Hello-World/tree/master",
217217
"self"=>"https://api.github.com/repos/octocat/Hello-World/branches/master"}}
218218

219+
MERGE_COMMIT = {"commit"=>
220+
{"sha"=>"7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
221+
"commit"=>
222+
{"author"=>
223+
{"name"=>"The Octocat",
224+
"date"=>"2012-03-06T15:06:50-08:00",
225+
"email"=>"octocat@nowhere.com"},
226+
"url"=>
227+
"https://api.github.com/repos/octocat/Hello-World/git/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
228+
"message"=>
229+
"Shipped cool_feature!",
230+
"tree"=>
231+
{"sha"=>"b4eecafa9be2f2006ce1b709d6857b07069b4608",
232+
"url"=>
233+
"https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608"},
234+
"committer"=>
235+
{"name"=>"The Octocat",
236+
"date"=>"2012-03-06T15:06:50-08:00",
237+
"email"=>"octocat@nowhere.com"}},
238+
"author"=>
239+
{"gravatar_id"=>"7ad39074b0584bc555d0417ae3e7d974",
240+
"avatar_url"=>
241+
"https://secure.gravatar.com/avatar/7ad39074b0584bc555d0417ae3e7d974?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
242+
"url"=>"https://api.github.com/users/octocat",
243+
"id"=>583231,
244+
"login"=>"octocat"},
245+
"parents"=>
246+
[{"sha"=>"553c2077f0edc3d5dc5d17262f6aa498e69d6f8e",
247+
"url"=>
248+
"https://api.github.com/repos/octocat/Hello-World/commits/553c2077f0edc3d5dc5d17262f6aa498e69d6f8e"},
249+
{"sha"=>"762941318ee16e59dabbacb1b4049eec22f0d303",
250+
"url"=>
251+
"https://api.github.com/repos/octocat/Hello-World/commits/762941318ee16e59dabbacb1b4049eec22f0d303"}],
252+
"url"=>
253+
"https://api.github.com/repos/octocat/Hello-World/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d",
254+
"committer"=>
255+
{"gravatar_id"=>"7ad39074b0584bc555d0417ae3e7d974",
256+
"avatar_url"=>
257+
"https://secure.gravatar.com/avatar/7ad39074b0584bc555d0417ae3e7d974?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
258+
"url"=>"https://api.github.com/users/octocat",
259+
"id"=>583231,
260+
"login"=>"octocat"}}}
261+
219262
MILESTONE = {
220263
"url" => "https://api.github.com/repos/octocat/Hello-World/milestones/1",
221264
"number" => 1,

0 commit comments

Comments
 (0)