Skip to content

Commit a9e7d7d

Browse files
committed
Merge pull request github#1024 from STRd6/patch-1
Update refs.md
2 parents 15730fb + e77a284 commit a9e7d7d

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

content/v3/git/refs.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,26 @@ The `ref` in the URL must be formatted as `heads/branch`, not just `branch`. For
1414

1515
GET /repos/:owner/:repo/git/refs/heads/skunkworkz/featureA
1616

17-
### Response
18-
1917
<%= headers 200 %>
2018
<%= json :ref %>
2119

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/feature-branch-that-no-longer-exists
33+
34+
<%= headers 404 %>
35+
<%= json :refs_not_found %>
36+
2237
## Get all References
2338

2439
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)