Skip to content

Commit 460d5bf

Browse files
committed
Added examples for getRef, createRef, deleteRef.
1 parent fcc12b3 commit 460d5bf

File tree

1 file changed

+37
-45
lines changed

1 file changed

+37
-45
lines changed

README.md

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,65 +33,71 @@ var repo = github.getRepo(username, reponame);
3333
Retrieve all available branches (aka heads) of a repository.
3434

3535
```js
36-
repo.listBranches(function(err, branches) {
37-
38-
});
36+
repo.listBranches(function(err, branches) {});
3937
```
4038

4139
Store contents at a certain path, where files that don't yet exist are created on the fly.
4240

4341
```js
44-
repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE', function(err) {
45-
46-
});
42+
repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE', function(err) {});
4743
```
4844

4945
Not only can you can write files, you can of course read them.
5046

5147
```js
52-
repo.read('master', 'path/to/file', function(err, data) {
53-
54-
});
48+
repo.read('master', 'path/to/file', function(err, data) {});
5549
```
5650

5751
Move a file from A to B.
5852

5953
```js
60-
repo.move('master', 'path/to/file', 'path/to/new_file', function(err) {
61-
62-
});
54+
repo.move('master', 'path/to/file', 'path/to/new_file', function(err) {});
6355
```
6456

6557
Remove a file.
6658

6759
```js
68-
repo.remove('master', 'path/to/file', function(err) {
69-
70-
});
60+
repo.remove('master', 'path/to/file', function(err) {});
7161
```
7262

7363
Exploring files of a repository is easy too by accessing the top level tree object.
7464

7565
```js
76-
repo.getTree('master', function(err, tree) {
77-
78-
});
66+
repo.getTree('master', function(err, tree) {});
7967
```
8068

8169
If you want to access all blobs and trees recursively, you can add `?recursive=true`.
8270

8371
```js
84-
repo.getTree('master?recursive=true', function(err, tree) {
85-
86-
});
72+
repo.getTree('master?recursive=true', function(err, tree) {});
8773
```
8874

8975
Given a filepath, retrieve the reference blob or tree sha.
9076

9177
```js
92-
repo.getSha('master', '/path/to/file', function(err, sha) {
93-
94-
});
78+
repo.getSha('master', '/path/to/file', function(err, sha) {});
79+
```
80+
81+
For a given reference, get the corresponding commit sha.
82+
83+
```js
84+
repo.getRef('heads/master', function(err, sha) {});
85+
```
86+
87+
Create a new reference.
88+
89+
```js
90+
var refSpec = {
91+
"ref": "refs/heads/my-new-branch-name",
92+
"sha": "827efc6d56897b048c772eb4087f854f46256132"
93+
};
94+
repo.createRef(refSpec, function(err) {});
95+
```
96+
97+
Delete a reference.
98+
99+
```js
100+
repo.deleteRef('heads/gh-pages', function(err) {});
95101
```
96102

97103

@@ -105,57 +111,43 @@ var user = github.getUser();
105111
List all repositories of the authenticated user.
106112

107113
```js
108-
user.repos(username, function(err, orgs) {
109-
110-
});
114+
user.repos(username, function(err, orgs) {});
111115
```
112116

113117
List organizations the autenticated user belongs to.
114118

115119
```js
116-
user.orgs(function(err, orgs) {
117-
118-
});
120+
user.orgs(function(err, orgs) {});
119121
```
120122

121123
List authenticated user's gists.
122124

123125
```js
124-
user.gists(username, function(err, gists) {
125-
126-
});
126+
user.gists(username, function(err, gists) {});
127127
```
128128

129129
Show user information for a particular username. Also works for organizations.
130130

131131
```js
132-
user.show(username, function(err, user) {
133-
134-
});
132+
user.show(username, function(err, user) {});
135133
```
136134

137135
List public repositories for a particular user.
138136

139137
```js
140-
user.userRepos(username, function(err, repos) {
141-
142-
});
138+
user.userRepos(username, function(err, repos) {});
143139
```
144140

145141
List repositories for a particular organization. Includes private repositories if you are authorized.
146142

147143
```js
148-
user.orgRepos(orgname, function(err, repos) {
149-
150-
});
144+
user.orgRepos(orgname, function(err, repos) {});
151145
```
152146

153147
List all gists of a particular user. If username is ommitted gists of the current authenticated user are returned.
154148

155149
```js
156-
user.userGists(username, function(err, gists) {
157-
158-
});
150+
user.userGists(username, function(err, gists) {});
159151
```
160152

161153
## Gist API

0 commit comments

Comments
 (0)