Skip to content

Commit 524e1d7

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent 1a09e82 commit 524e1d7

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
kind: change
3+
title: Commit Reference SHA-1 Preview Period
4+
author_name: mikemcquaid
5+
---
6+
7+
We're introducing a new API media type to allow users to get the SHA-1 of a commit reference. This can be useful in working out if you have the latest version of a remote branch based on your local branch's SHA-1. Developers with read access to a repository can start experimenting with this new media type today during the preview period.
8+
9+
To get the commit reference's SHA-1, make a `GET` request to the repository's reference:
10+
11+
``` command-line
12+
$ curl "https://api.github.com/repos/Homebrew/homebrew/commits/master" \
13+
-H "Accept: application/vnd.github.chitauri-preview+sha"
14+
```
15+
16+
To check if a remote branch's SHA-1 is the same as your local branch's SHA-1, make a `GET` request to the repository's branch and provide the current SHA-1 for the local branch as the ETag:
17+
18+
``` command-line
19+
$ curl "https://api.github.com/repos/Homebrew/homebrew/commits/master" \
20+
-H "Accept: application/vnd.github.chitauri-preview+sha" \
21+
-H "If-None-Match: \"814412cfbd631109df337e16c807207e78c0d24e\""
22+
```
23+
24+
If the remote and your local branch point to the same SHA-1 then this call will return a `304 Unmodified` status code (and not use your rate limit).
25+
26+
You can see an example of this API in a pull request to Homebrew/homebrew's updater: https://github.com/Homebrew/homebrew/pull/49219.
27+
28+
#### How can I try it?
29+
30+
To use this new API media type during the preview period, you’ll need to provide the following custom [media type][media-types] in the `Accept` header:
31+
32+
```
33+
application/vnd.github.chitauri-preview+sha
34+
```
35+
36+
During the preview period, we may change aspects of this API media type based on developer feedback. If we do, we will announce the changes here on the developer blog, but we will not provide any advance notice.
37+
38+
Take a look at [the documentation][docs] and, if you have any questions, please [get in touch][contact].
39+
40+
[contact]: https://github.com/contact?form%5Bsubject%5D=Commit+Reference+SHA-1+Preview
41+
[docs]: /v3/repos/commits/#get-the-sha-1-of-a-commit-reference
42+
[media-types]: /v3/media/

content/v3/repos/commits.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,37 @@ patch formats.
4343
<%= headers 200 %>
4444
<%= json(:full_commit) %>
4545

46+
## Get the SHA-1 of a commit reference
47+
48+
{{#tip}}
49+
50+
<a name="preview-period"></a>
51+
52+
The API to get the SHA-1 of a commit reference is currently available for developers to preview.
53+
During the preview period, the API may change without advance notice.
54+
Please see the [blog post](/changes/2016-02-24-commit-reference-sha-api) for full details.
55+
56+
To access the API you must provide a custom [media type](/v3/media) in the `Accept` header:
57+
58+
application/vnd.github.chitauri-preview+sha
59+
60+
{{/tip}}
61+
62+
Users with read access can get the SHA-1 of a commit reference:
63+
64+
GET /repos/:owner/:repo/commits/:ref
65+
66+
To check if a remote reference's SHA-1 is the same as your local reference's SHA-1, make a `GET` request and provide the current SHA-1 for the local reference as the ETag.
67+
68+
### Response
69+
70+
The SHA-1 of the commit reference.
71+
72+
<%= headers 200 %>
73+
<pre>
74+
814412cfbd631109df337e16c807207e78c0d24e
75+
</pre>
76+
4677
## Compare two commits
4778

4879
GET /repos/:owner/:repo/compare/:base...:head

0 commit comments

Comments
 (0)