@@ -3,31 +3,49 @@ Github.js
3
3
4
4
Ever wanted to store a file on Github right from the browser? Here you are.
5
5
6
+
7
+ Expose API for a given repository.
8
+
6
9
``` js
7
10
var github = new Github ({
8
11
username: " YOU_USER" ,
9
12
password: " YOUR_PASSWORD" ,
10
13
auth: " basic"
11
14
});
12
15
13
- // Expose API for a given repository
14
-
15
16
var repo = github .getRepo (reponame);
17
+ ```
18
+
19
+ Retrieve all available branches (aka heads) of a repository.
16
20
17
- // Store contents at a certain path (assumes UTF-8)
18
- // Files that don't yet exist are created on the fly.
21
+ ``` js
22
+ repo .listBranches , function (err , branches ) {
23
+
24
+ });
25
+ ```
19
26
20
- repo .write (' path/to/file' , ' YOUR_NEW_CONTENTS' , ' YOUR_COMMIT_MESSAGE' , function (err ) {
27
+ Store contents at a certain path, where files that don't yet exist are created on the fly.
28
+
29
+ ``` js
30
+ repo .write (' master' , ' path/to/file' , ' YOUR_NEW_CONTENTS' , ' YOUR_COMMIT_MESSAGE' , function (err ) {
31
+
32
+ });
33
+ ```
34
+
35
+ Not only can you can write files, you can of course read them.
36
+
37
+ ``` js
38
+ repo .read (' master' , ' path/to/file' , function (err , data ) {
21
39
22
40
});
23
41
```
24
42
25
- Not only can you can write files, you can of course read them:
43
+ Listing all files of a repository is easy too.
26
44
27
45
``` js
28
46
// Retrieve contents of a certain file (assumes UTF-8)
29
47
30
- repo .read ( ' path/to/file' , function (err , data ) {
48
+ repo .list ( ' master ' , ' path/to/file' , function (err , data ) {
31
49
32
50
});
33
51
```
0 commit comments