Skip to content

Commit 3d4219b

Browse files
committed
Really beefed up example
1 parent e13f63f commit 3d4219b

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

content/v3/git/refs.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ title: Git Refs
1313
The `ref` in the URL must be formatted as `heads/branch`, not just `branch`. For example, the call to get the data for a branch named `skunkworkz/featureA` would be:
1414

1515
GET /repos/:owner/:repo/git/refs/heads/skunkworkz/featureA
16-
17-
If the `ref` doesn't exist in the repository, but existing refs start with `ref` they will be returned as an array.
18-
19-
### Response
2016

2117
<%= headers 200 %>
2218
<%= json :ref %>
2319

20+
If the ref doesn't exist in the repository, but existing refs start with ref
21+
they will be returned as an array. For example, a call to get the data for a
22+
branch named `feature`, which doesn't exist, would return head refs
23+
including `featureA` and `featureB` which do.
24+
25+
GET /repos/:owner/:repo/git/refs/heads/feature
26+
27+
<%= headers 200 %>
28+
<%= json :refs_matching %>
29+
30+
If the ref doesn't match an existing ref or any prefixes a 404 will be returned.
31+
32+
GET /repos/:owner/:repo/git/refs/heads/ref-that-like-for-sure-totally-doesnt-exist
33+
34+
<%= headers 404 %>
35+
<%= json :refs_not_found %>
36+
2437
## Get all References
2538

2639
GET /repos/:owner/:repo/git/refs

lib/responses/git.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,32 @@ module Responses
422422
}
423423
}
424424
]
425+
426+
REFS_MATCHING ||= [
427+
{
428+
"ref" => "refs/heads/feature-a",
429+
"url" => "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature-a",
430+
"object" => {
431+
"type" => "commit",
432+
"sha" => "aa218f56b14c9653891f9e74264a383fa43fefbd",
433+
"url" => "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
434+
}
435+
},
436+
{
437+
"ref" => "refs/heads/feature-b",
438+
"url" => "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature-b",
439+
"object" => {
440+
"type" => "commit",
441+
"sha" => "612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac",
442+
"url" => "https://api.github.com/repos/octocat/Hello-World/git/commits/612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac"
443+
}
444+
}
445+
]
446+
447+
REFS_NOT_FOUND ||= {
448+
"message" => "Not Found",
449+
"documentation_url" => "https://developer.github.com/v3"
450+
}
425451
end
426452
end
427453
end

0 commit comments

Comments
 (0)