|
5 | 5 |
|
6 | 6 | let eventType = undefined
|
7 | 7 | let aroundDate = undefined
|
| 8 | + let repository = undefined |
8 | 9 |
|
9 | 10 | // parse arguments, e.g. --event-type=check_run --date='Tue, 21 Nov 2023 11:13:12 GMT'
|
10 | 11 | const args = process.argv.slice(2)
|
|
37 | 38 | const arg = getArg()
|
38 | 39 | if (isNaN(Date.parse(arg))) throw new Error(`--date requires a valid date (got '${arg}')`)
|
39 | 40 | aroundDate = new Date(arg)
|
40 |
| - } else |
| 41 | + } else if (option === '--repository') repository = getArg() |
| 42 | + else |
41 | 43 | throw new Error(`Unhandled option: '${option}`)
|
42 | 44 | }
|
43 | 45 |
|
|
48 | 50 | process.env.GITHUB_APP_ID = localSettings.Values.GITHUB_APP_ID
|
49 | 51 | process.env.GITHUB_APP_PRIVATE_KEY = localSettings.Values.GITHUB_APP_PRIVATE_KEY
|
50 | 52 |
|
| 53 | + const repositoryID = !repository ? false : await (async () => { |
| 54 | + const [owner, repo] = repository.split('/') |
| 55 | + const getInstallationIdForRepo = require('./GitForWindowsHelper/get-installation-id-for-repo') |
| 56 | + const installationId = await getInstallationIdForRepo(console, owner, repo) |
| 57 | + const getInstallationAccessToken = require('./GitForWindowsHelper/get-installation-access-token') |
| 58 | + const token = await getInstallationAccessToken(console, installationId) |
| 59 | + const gitHubRequest = require('./GitForWindowsHelper/github-api-request') |
| 60 | + return (await gitHubRequest(console, token, 'GET', `/repos/${repository}`)).id |
| 61 | + })() |
| 62 | + |
51 | 63 | const gitHubRequestAsApp = require('./GitForWindowsHelper/github-api-request-as-app')
|
52 | 64 |
|
53 | 65 | const getAtCursor = async cursor => {
|
|
61 | 73 | if (eventType && e.event !== eventType) return false
|
62 | 74 | if (since && e.epoch < since) return false
|
63 | 75 | if (until && e.epoch > until) return false
|
| 76 | + if (repositoryID && e.repository_id !== repositoryID) return false |
64 | 77 | return true
|
65 | 78 | })
|
66 | 79 | const newest = answer.shift()
|
|
0 commit comments