Skip to content

Commit a6692d4

Browse files
committed
Add docs for Gitignore Templates API
1 parent 414f027 commit a6692d4

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

content/v3/repos/gitignore.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Gitignore templates | GitHub API
3+
---
4+
5+
# Gitignore Templates API
6+
7+
* TOC
8+
{:toc}
9+
10+
When you create a new GitHub repository via the API, you can specify a
11+
[.gitignore template][what-is] to apply to the repository upon creation. The
12+
.gitignore Templates API lists and fetches templates from the [GitHub .gitignore repository][templates-repo].
13+
14+
## Listing available templates
15+
16+
List all templates available to pass as an option when [creating a repository][create-repo].
17+
18+
GET /gitignore/templates
19+
20+
### Response
21+
22+
<%= headers 200 %>
23+
<%= json(:templates) %>
24+
25+
## Get a single template
26+
27+
The API also allows fetching the source of a single template.
28+
29+
GET /gitignore/templates/C
30+
31+
### Response
32+
33+
<%= headers 200 %>
34+
<%= json(:template) %>
35+
36+
Use the raw [media type][media-type] to get the raw contents.
37+
38+
<%= headers 200 %>
39+
<pre>
40+
# Object files
41+
*.o
42+
43+
# Libraries
44+
*.lib
45+
*.a
46+
47+
# Shared objects (inc. Windows DLLs)
48+
*.dll
49+
*.so
50+
*.so.*
51+
*.dylib
52+
53+
# Executables
54+
*.exe
55+
*.out
56+
*.app
57+
</pre>
58+
59+
[what-is]: https://help.github.com/articles/ignoring-files
60+
[templates-repo]: https://github.com/github/gitignore
61+
[create-repo]: /v3/repos/#create
62+
[media-type]: /v3/media/

layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ <h3><a href="#" class="js-expand-btn collapsed">&nbsp;</a><a href="/v3/repos/">R
107107
<li><a href="/v3/repos/contents/">Contents</a></li>
108108
<li><a href="/v3/repos/downloads/">Downloads</a></li>
109109
<li><a href="/v3/repos/forks/">Forks</a></li>
110+
<li><a href="/v3/repos/gitignore/">Gitignore</a></li>
110111
<li><a href="/v3/repos/keys/">Keys</a></li>
111112
<li><a href="/v3/repos/hooks/">Hooks</a></li>
112113
<li><a href="/v3/repos/merging/">Merging</a></li>

lib/resources.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def text_html(response, status, head = {})
9393
res = CGI.escapeHTML(response)
9494
hs + %(<pre class="highlight"><code>) + res + "</code></pre>"
9595
end
96+
9697
end
9798

9899
USER = {
@@ -997,6 +998,21 @@ def text_html(response, status, head = {})
997998
:url => "https://api.github.com/repos/octocat/example/subscription",
998999
:repository_url => "https://api.github.com/repos/octocat/example"
9991000
REPO_SUBSCRIPTION.delete :thread_url
1001+
1002+
TEMPLATE = {
1003+
:name => "C",
1004+
:source => "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n"
1005+
}
1006+
1007+
TEMPLATES = [
1008+
"Actionscript",
1009+
"Android",
1010+
"AppceleratorTitanium",
1011+
"Autotools",
1012+
"Bancha",
1013+
"C",
1014+
"C++"
1015+
]
10001016
end
10011017
end
10021018

0 commit comments

Comments
 (0)