ghrepos 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +20 -0
- package/.github/workflows/test-and-release.yml +56 -0
- package/CHANGELOG.md +19 -0
- package/README.md +64 -146
- package/examples/commit-comments.js +11 -13
- package/ghrepos.js +52 -89
- package/package.json +101 -8
- package/test.js +196 -371
- package/.jshintrc +0 -59
- package/.travis.yml +0 -17
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: 'github-actions'
|
|
4
|
+
directory: '/'
|
|
5
|
+
schedule:
|
|
6
|
+
interval: 'weekly'
|
|
7
|
+
commit-message:
|
|
8
|
+
prefix: 'chore'
|
|
9
|
+
include: 'scope'
|
|
10
|
+
cooldown:
|
|
11
|
+
default-days: 5
|
|
12
|
+
- package-ecosystem: 'npm'
|
|
13
|
+
directory: '/'
|
|
14
|
+
schedule:
|
|
15
|
+
interval: 'weekly'
|
|
16
|
+
commit-message:
|
|
17
|
+
prefix: 'chore'
|
|
18
|
+
include: 'scope'
|
|
19
|
+
cooldown:
|
|
20
|
+
default-days: 5
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Test & Maybe Release
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
test:
|
|
6
|
+
strategy:
|
|
7
|
+
fail-fast: false
|
|
8
|
+
matrix:
|
|
9
|
+
node: [lts/*, current]
|
|
10
|
+
os: [macos-latest, ubuntu-latest, windows-latest]
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout Repository
|
|
14
|
+
uses: actions/checkout@v6
|
|
15
|
+
- name: Use Node.js ${{ matrix.node }}
|
|
16
|
+
uses: actions/setup-node@v6.3.0
|
|
17
|
+
with:
|
|
18
|
+
node-version: ${{ matrix.node }}
|
|
19
|
+
- name: Install Dependencies
|
|
20
|
+
run: npm install --no-progress
|
|
21
|
+
- name: Check build is up to date
|
|
22
|
+
run: |
|
|
23
|
+
npm run build
|
|
24
|
+
git diff --exit-code || (echo "::error::Build artifacts not committed. Run 'npm run build' and commit the changes." && exit 1)
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: npm test
|
|
27
|
+
|
|
28
|
+
release:
|
|
29
|
+
name: Release
|
|
30
|
+
needs: test
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
issues: write
|
|
36
|
+
pull-requests: write
|
|
37
|
+
id-token: write
|
|
38
|
+
steps:
|
|
39
|
+
- name: Checkout
|
|
40
|
+
uses: actions/checkout@v6
|
|
41
|
+
with:
|
|
42
|
+
fetch-depth: 0
|
|
43
|
+
- name: Setup Node.js
|
|
44
|
+
uses: actions/setup-node@v6.3.0
|
|
45
|
+
with:
|
|
46
|
+
node-version: lts/*
|
|
47
|
+
registry-url: 'https://registry.npmjs.org'
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: npm install --no-progress --no-package-lock --no-save
|
|
50
|
+
- name: Build
|
|
51
|
+
run: npm run build
|
|
52
|
+
- name: Release
|
|
53
|
+
env:
|
|
54
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
55
|
+
NPM_CONFIG_PROVENANCE: true
|
|
56
|
+
run: npx semantic-release
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## [3.0.1](https://github.com/rvagg/ghrepos/compare/v3.0.0...v3.0.1) (2026-04-28)
|
|
2
|
+
|
|
3
|
+
### Trivial Changes
|
|
4
|
+
|
|
5
|
+
* **deps:** bump actions/setup-node from 6 to 6.3.0 ([#8](https://github.com/rvagg/ghrepos/issues/8)) ([77f2065](https://github.com/rvagg/ghrepos/commit/77f2065c68d0b875c91b877a8ee95a9d92109fdb))
|
|
6
|
+
|
|
7
|
+
## [3.0.0](https://github.com/rvagg/ghrepos/compare/v2.1.0...v3.0.0) (2026-01-27)
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* modernise, ESM, promises, update deps, GHA, auto-release (#7)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* add release config ([8fcbd12](https://github.com/rvagg/ghrepos/commit/8fcbd128551da685b0f227289dfe1e441b90ece1))
|
|
16
|
+
|
|
17
|
+
### Trivial Changes
|
|
18
|
+
|
|
19
|
+
* modernise, ESM, promises, update deps, GHA, auto-release ([#7](https://github.com/rvagg/ghrepos/issues/7)) ([8ad433d](https://github.com/rvagg/ghrepos/commit/8ad433d162b20c64f0331cdd1e2afd369027db87))
|
package/README.md
CHANGED
|
@@ -1,201 +1,119 @@
|
|
|
1
1
|
# ghrepos
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A Node.js library to interact with the GitHub repos API**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://nodei.co/npm/ghrepos/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Requirements
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Node.js >= 20
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
* https://github.com/rvagg/ghusers
|
|
13
|
-
* https://github.com/rvagg/ghteams
|
|
14
|
-
* https://github.com/rvagg/ghauth
|
|
11
|
+
## Example usage
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
```js
|
|
14
|
+
import * as ghrepos from 'ghrepos'
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
const auth = { token: 'your-github-token' }
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
// list all repos for a user
|
|
19
|
+
const repos = await ghrepos.listUser(auth, 'rvagg')
|
|
20
|
+
console.log(repos)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// list all repos for an org
|
|
23
|
+
const orgRepos = await ghrepos.listOrg(auth, 'nodejs')
|
|
24
|
+
console.log(orgRepos)
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
26
|
+
// get branch data
|
|
27
|
+
const branch = await ghrepos.getBranch(auth, 'nodejs', 'node', 'main')
|
|
28
|
+
console.log(branch)
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
// get commit comments
|
|
31
|
+
const comments = await ghrepos.getCommitComments(auth, 'nodejs', 'node', '75318e46b')
|
|
32
|
+
console.log(comments)
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
List all repos for a organisation. If `org` and `options` are omitted the current org is assumed.
|
|
36
|
-
|
|
37
|
-
List all repos for org `'nodejs'`:
|
|
35
|
+
The auth data is compatible with [ghauth](https://github.com/rvagg/ghauth) so you can connect them together:
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
import ghauth from 'ghauth'
|
|
39
|
+
import * as ghrepos from 'ghrepos'
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const auth = await ghauth({
|
|
42
|
+
configName: 'repo-lister',
|
|
43
|
+
scopes: ['user']
|
|
45
44
|
})
|
|
46
|
-
```
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Get all ref data for `nodejs/node` repo:
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
ghrepos.listRefs(authOptions, 'nodejs', 'node', function (err, refData) {
|
|
56
|
-
// data containing ref information including sha and github url
|
|
57
|
-
console.log(refData)
|
|
46
|
+
const repos = await ghrepos.listUser(auth, 'rvagg')
|
|
47
|
+
console.log('Repos for rvagg:')
|
|
48
|
+
repos.forEach((r) => {
|
|
49
|
+
console.log('%s: %s (fork: %s)', r.name, r.description, r.fork)
|
|
58
50
|
})
|
|
59
51
|
```
|
|
60
52
|
|
|
61
|
-
|
|
53
|
+
## API
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
All methods return Promises.
|
|
64
56
|
|
|
65
|
-
|
|
57
|
+
### ghrepos.listUser(auth, user, options)
|
|
66
58
|
|
|
67
|
-
|
|
68
|
-
ghrepos.listBranches(authOptions, 'nodejs', 'node', function (err, refData) {
|
|
69
|
-
// data containing branch information including sha and github API url
|
|
70
|
-
console.log(refData)
|
|
71
|
-
})
|
|
72
|
-
```
|
|
59
|
+
List all repos for a user. If `user` is falsy, lists repos for the authenticated user.
|
|
73
60
|
|
|
74
|
-
###
|
|
61
|
+
### ghrepos.listOrg(auth, org, options)
|
|
75
62
|
|
|
76
|
-
List
|
|
63
|
+
List all repos for an organisation.
|
|
77
64
|
|
|
78
|
-
|
|
65
|
+
### ghrepos.listRefs(auth, org, repo, options)
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
ghrepos.listCommits(authOptions, 'nodejs', 'node', function (err, refData) {
|
|
82
|
-
// data containing commit information including sha and github API url
|
|
83
|
-
console.log(refData)
|
|
84
|
-
})
|
|
85
|
-
```
|
|
67
|
+
Get git ref data for all refs in a repo.
|
|
86
68
|
|
|
87
|
-
### listTags(auth, org, repo
|
|
69
|
+
### ghrepos.listTags(auth, org, repo, options)
|
|
88
70
|
|
|
89
71
|
List git tags for a repo.
|
|
90
72
|
|
|
91
|
-
|
|
73
|
+
### ghrepos.listBranches(auth, org, repo, options)
|
|
92
74
|
|
|
93
|
-
|
|
94
|
-
ghrepos.listTags(authOptions, 'nodejs', 'node', function (err, refData) {
|
|
95
|
-
// data containing tag information including sha and github API url
|
|
96
|
-
console.log(refData)
|
|
97
|
-
})
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### getRef(auth, org, repo, ref[, options], callback)
|
|
101
|
-
|
|
102
|
-
Get git ref data for a particular ref string.
|
|
103
|
-
|
|
104
|
-
Get git ref data for `v1.x` branch in `nodejs/node` repo:
|
|
105
|
-
|
|
106
|
-
```js
|
|
107
|
-
ghrepos.getRef(authOptions, 'nodejs', 'node', 'heads/v1.x', function (err, refData) {
|
|
108
|
-
// data containing ref information including sha and github url
|
|
109
|
-
console.log(refData)
|
|
110
|
-
})
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### getBranch(auth, org, repo, branch[, options], callback)
|
|
114
|
-
|
|
115
|
-
Get git branch data for a given branch name
|
|
75
|
+
List git branches for a repo.
|
|
116
76
|
|
|
117
|
-
|
|
77
|
+
### ghrepos.listCommits(auth, org, repo, options)
|
|
118
78
|
|
|
119
|
-
|
|
120
|
-
ghrepos.getBranch(authOptions, 'nodejs', 'node', 'v1.x', function (err, refData) {
|
|
121
|
-
// data containing branch information including sha and github API url
|
|
122
|
-
console.log(refData)
|
|
123
|
-
})
|
|
124
|
-
```
|
|
79
|
+
List git commits for a repo.
|
|
125
80
|
|
|
126
|
-
###
|
|
81
|
+
### ghrepos.getRef(auth, org, repo, ref, options)
|
|
127
82
|
|
|
128
|
-
Get git
|
|
83
|
+
Get git ref data for a particular ref string. The `refs/` prefix is automatically stripped if present.
|
|
129
84
|
|
|
130
|
-
|
|
85
|
+
### ghrepos.getBranch(auth, org, repo, branch, options)
|
|
131
86
|
|
|
132
|
-
|
|
133
|
-
ghrepos.getCommit(authOptions, 'nodejs', 'node', '75318e46b', function (err, refData) {
|
|
134
|
-
// data containing commit information including sha and github API url
|
|
135
|
-
console.log(refData)
|
|
136
|
-
})
|
|
137
|
-
```
|
|
87
|
+
Get git branch data for a given branch name.
|
|
138
88
|
|
|
139
|
-
###
|
|
89
|
+
### ghrepos.getCommit(auth, org, repo, sha, options)
|
|
140
90
|
|
|
141
|
-
Get git commit
|
|
91
|
+
Get git commit data for a given SHA.
|
|
142
92
|
|
|
143
|
-
|
|
93
|
+
### ghrepos.getCommitComments(auth, org, repo, sha, options)
|
|
144
94
|
|
|
145
|
-
|
|
146
|
-
ghrepos.getCommitComments(authOptions, 'nodejs', 'node', '75318e46b', function (err, comments) {
|
|
147
|
-
// array containing commit comments information
|
|
148
|
-
console.log(JSON.stringify(comments.map(function (i) {
|
|
149
|
-
return { user: i.user.login, body: i.body }
|
|
150
|
-
}), null, 2))
|
|
151
|
-
})
|
|
152
|
-
```
|
|
95
|
+
Get commit comments for a given SHA.
|
|
153
96
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```json
|
|
157
|
-
[
|
|
158
|
-
{
|
|
159
|
-
"user": "Trott",
|
|
160
|
-
"body": "@cjihrig There's no PR-URL on this commit message. (`core-validate-commit` FTW as usual!)"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"user": "mscdex",
|
|
164
|
-
"body": "PR-URL is: https://github.com/nodejs/node/pull/15745"
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
```
|
|
97
|
+
### ghrepos.createLister(type)
|
|
168
98
|
|
|
169
|
-
|
|
99
|
+
Creates a function that lists sub-resources under `/repos/:org/:repo/:type`, e.g. `'issues'`, `'pulls'` or `'releases'`. The returned function has the signature: `async function (auth, org, repo, options)`.
|
|
170
100
|
|
|
171
|
-
|
|
101
|
+
### ghrepos.baseUrl(org, repo, options)
|
|
172
102
|
|
|
173
|
-
|
|
103
|
+
Returns the base API URL for a repo: `https://api.github.com/repos/:org/:repo`.
|
|
174
104
|
|
|
105
|
+
## Authentication
|
|
175
106
|
|
|
176
|
-
|
|
107
|
+
See [ghauth](https://github.com/rvagg/ghauth) for an easy way to obtain and cache GitHub authentication tokens. The `auth` object returned by ghauth is directly compatible with all ghrepos methods.
|
|
177
108
|
|
|
178
|
-
|
|
179
|
-
const ghauth = require('ghauth')
|
|
180
|
-
, ghrepos = require('ghrepos')
|
|
181
|
-
, authOptions = {
|
|
182
|
-
configName : 'lister'
|
|
183
|
-
, scopes : [ 'user' ]
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
ghauth(authOptions, function (err, authData) {
|
|
187
|
-
ghrepos.listUser(authData, 'rvagg', function (err, list) {
|
|
188
|
-
console.log('Repos for rvagg:')
|
|
189
|
-
console.log(util.inspect(list.map(function (i) { return {
|
|
190
|
-
name: i.name
|
|
191
|
-
, desc: i.description
|
|
192
|
-
, fork: i.fork
|
|
193
|
-
}})))
|
|
194
|
-
})
|
|
195
|
-
})
|
|
196
|
-
```
|
|
109
|
+
## See also
|
|
197
110
|
|
|
111
|
+
* [ghissues](https://github.com/rvagg/ghissues) - interact with the GitHub issues API
|
|
112
|
+
* [ghusers](https://github.com/rvagg/ghusers) - interact with the GitHub users API
|
|
113
|
+
* [ghteams](https://github.com/rvagg/ghteams) - interact with the GitHub teams API
|
|
114
|
+
* [ghpulls](https://github.com/rvagg/ghpulls) - interact with the GitHub pull requests API
|
|
115
|
+
* [ghauth](https://github.com/rvagg/ghauth) - GitHub authentication
|
|
198
116
|
|
|
199
117
|
## License
|
|
200
118
|
|
|
201
|
-
**ghrepos** is Copyright (c)
|
|
119
|
+
**ghrepos** is Copyright (c) 2014-2025 Rod Vagg [@rvagg](https://github.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
, authOptions = {
|
|
4
|
-
configName : 'lister'
|
|
5
|
-
, scopes : [ 'user' ]
|
|
6
|
-
}
|
|
1
|
+
import ghauth from 'ghauth'
|
|
2
|
+
import { getCommitComments } from '../ghrepos.js'
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return { user: i.user.login, body: i.body }
|
|
13
|
-
}), null, 2))
|
|
14
|
-
})
|
|
4
|
+
const authData = await ghauth({
|
|
5
|
+
configName: 'lister',
|
|
6
|
+
clientId: 'your-client-id',
|
|
7
|
+
scopes: ['user']
|
|
15
8
|
})
|
|
9
|
+
|
|
10
|
+
const comments = await getCommitComments(authData, 'nodejs', 'node', '75318e46b')
|
|
11
|
+
console.log(JSON.stringify(comments.map((i) => {
|
|
12
|
+
return { user: i.user.login, body: i.body }
|
|
13
|
+
}), null, 2))
|
package/ghrepos.js
CHANGED
|
@@ -1,109 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
, apiRoot = ghutils.apiRoot
|
|
1
|
+
import { apiRoot, ghget, lister } from 'ghutils'
|
|
3
2
|
|
|
3
|
+
const defaultApiUrl = apiRoot
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
export function baseUrl (org, repo, options = {}) {
|
|
6
|
+
const api = options._apiUrl || defaultApiUrl
|
|
7
|
+
return `${api}/repos/${org}/${repo}`
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export async function listUser (auth, user, options = {}) {
|
|
11
|
+
const api = options._apiUrl || defaultApiUrl
|
|
12
|
+
const url = user ? `${api}/users/${user}/repos` : `${api}/user/repos`
|
|
13
|
+
return lister(auth, url, options)
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
options = {}
|
|
19
|
-
org = null
|
|
20
|
-
} else if (typeof options == 'function') { // no options
|
|
21
|
-
callback = options
|
|
22
|
-
options = {}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var urlbase = apiRoot
|
|
26
|
-
|
|
27
|
-
if (org == null) {
|
|
28
|
-
urlbase += '/user/repos'
|
|
29
|
-
} else {
|
|
30
|
-
if (type == 'org')
|
|
31
|
-
urlbase += '/orgs/' + org + '/repos?'
|
|
32
|
-
else
|
|
33
|
-
urlbase += '/users/' + org + '/repos?'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
ghutils.lister(auth, urlbase, options, callback)
|
|
16
|
+
export async function listOrg (auth, org, options = {}) {
|
|
17
|
+
const api = options._apiUrl || defaultApiUrl
|
|
18
|
+
const url = `${api}/orgs/${org}/repos`
|
|
19
|
+
return lister(auth, url, options)
|
|
37
20
|
}
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var lister = function (auth, org, repo, options, callback) {
|
|
44
|
-
if (typeof options == 'function') { // no options
|
|
45
|
-
callback = options
|
|
46
|
-
options = {}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var url = refsBaseUrl(org, repo, type)
|
|
50
|
-
ghutils.lister(auth, url, options, callback)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports['list' + type[0].toUpperCase() + type.substring(1)] = lister
|
|
54
|
-
|
|
55
|
-
if (type == 'tag')
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
// no getTag API
|
|
59
|
-
var getter = function (auth, org, repo, ref, options, callback) {
|
|
60
|
-
if (typeof options == 'function') {
|
|
61
|
-
callback = options
|
|
62
|
-
options = {}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// a valid ref but we're not using this format
|
|
66
|
-
ref = ref.replace(/^refs\//, '')
|
|
67
|
-
|
|
68
|
-
var url = refsBaseUrl(org, repo, type) + '/' + ref
|
|
69
|
-
ghutils.ghget(auth, url, options, callback)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports['get' + singular[0].toUpperCase() + singular.substring(1)] = getter
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
function getCommitComments (auth, org, repo, sha1, options, callback) {
|
|
76
|
-
var ref = sha1 + '/comments'
|
|
77
|
-
return module.exports.getCommit(auth, org, repo, ref, options, callback)
|
|
22
|
+
export async function listRefs (auth, org, repo, options = {}) {
|
|
23
|
+
const url = baseUrl(org, repo, options) + '/git/refs'
|
|
24
|
+
return lister(auth, url, options)
|
|
78
25
|
}
|
|
79
26
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
options = {}
|
|
85
|
-
}
|
|
27
|
+
export async function listTags (auth, org, repo, options = {}) {
|
|
28
|
+
const url = baseUrl(org, repo, options) + '/tags'
|
|
29
|
+
return lister(auth, url, options)
|
|
30
|
+
}
|
|
86
31
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
32
|
+
export async function listBranches (auth, org, repo, options = {}) {
|
|
33
|
+
const url = baseUrl(org, repo, options) + '/branches'
|
|
34
|
+
return lister(auth, url, options)
|
|
90
35
|
}
|
|
91
36
|
|
|
37
|
+
export async function listCommits (auth, org, repo, options = {}) {
|
|
38
|
+
const url = baseUrl(org, repo, options) + '/commits'
|
|
39
|
+
return lister(auth, url, options)
|
|
40
|
+
}
|
|
92
41
|
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
42
|
+
export async function getRef (auth, org, repo, ref, options = {}) {
|
|
43
|
+
ref = ref.replace(/^refs\//, '')
|
|
44
|
+
const url = baseUrl(org, repo, options) + '/git/refs/' + ref
|
|
45
|
+
const { data } = await ghget(auth, url, options)
|
|
46
|
+
return data
|
|
97
47
|
}
|
|
98
48
|
|
|
49
|
+
export async function getBranch (auth, org, repo, branch, options = {}) {
|
|
50
|
+
const url = baseUrl(org, repo, options) + '/branches/' + branch
|
|
51
|
+
const { data } = await ghget(auth, url, options)
|
|
52
|
+
return data
|
|
53
|
+
}
|
|
99
54
|
|
|
100
|
-
function
|
|
101
|
-
|
|
55
|
+
export async function getCommit (auth, org, repo, sha, options = {}) {
|
|
56
|
+
const url = baseUrl(org, repo, options) + '/commits/' + sha
|
|
57
|
+
const { data } = await ghget(auth, url, options)
|
|
58
|
+
return data
|
|
102
59
|
}
|
|
103
60
|
|
|
61
|
+
export async function getCommitComments (auth, org, repo, sha, options = {}) {
|
|
62
|
+
const url = baseUrl(org, repo, options) + '/commits/' + sha + '/comments'
|
|
63
|
+
const { data } = await ghget(auth, url, options)
|
|
64
|
+
return data
|
|
65
|
+
}
|
|
104
66
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
67
|
+
export function createLister (type) {
|
|
68
|
+
return async function (auth, org, repo, options = {}) {
|
|
69
|
+
const url = baseUrl(org, repo, options) + '/' + type
|
|
70
|
+
return lister(auth, url, options)
|
|
71
|
+
}
|
|
72
|
+
}
|