Skip to content

Commit 368445d

Browse files
committed
Release 1.3.2
Changes from 1.3.1: - list all commits by page - write json commits to local file `output-file` Signed-off-by: slasher <[email protected]>
1 parent 198af03 commit 368445d

File tree

8 files changed

+2252
-1321
lines changed

8 files changed

+2252
-1321
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ jobs:
1919
uses: tim-actions/get-pr-commits@master
2020
with:
2121
token: ${{ secrets.GITHUB_TOKEN }}
22+
output-file: "/tmp/commits.json"
2223
2324
```

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ inputs:
1212
description: 'Regex flags of input filter_out_pattern'
1313
required: false
1414
default: ''
15+
output-file:
16+
description: 'output json commits to file'
17+
required: false
18+
default: ''
1519
outputs:
1620
commits:
1721
description: 'commits in pr'

dist/index.js

Lines changed: 1972 additions & 1221 deletions
Large diffs are not rendered by default.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ The above copyright notice and this permission notice shall be included in all c
1010

1111
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1212

13+
@actions/exec
14+
MIT
15+
The MIT License (MIT)
16+
17+
Copyright 2019 GitHub
18+
19+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
1325
@actions/github
1426
MIT
1527

@@ -38,6 +50,18 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3850
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3951

4052

53+
@actions/io
54+
MIT
55+
The MIT License (MIT)
56+
57+
Copyright 2019 GitHub
58+
59+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
60+
61+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
62+
63+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64+
4165
@octokit/auth-token
4266
MIT
4367
The MIT License
@@ -1171,19 +1195,6 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
11711195
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11721196

11731197

1174-
uuid
1175-
MIT
1176-
The MIT License (MIT)
1177-
1178-
Copyright (c) 2010-2020 Robert Kieffer and other contributors
1179-
1180-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1181-
1182-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1183-
1184-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1185-
1186-
11871198
webidl-conversions
11881199
BSD-2-Clause
11891200
# The BSD 2-Clause License

index.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs')
12
const core = require('@actions/core')
23
const github = require('@actions/github')
34

@@ -12,18 +13,33 @@ async function main() {
1213
return
1314
}
1415

16+
const outfile = core.getInput('output-file')
1517
const token = core.getInput('token')
1618
const filterOutPattern = core.getInput('filter_out_pattern')
1719
const filterOutFlags = core.getInput('filter_out_flags')
1820
const octokit = new github.GitHub(token)
1921

20-
const commitsListed = await octokit.pulls.listCommits({
21-
owner: repo.owner.login,
22-
repo: repo.name,
23-
pull_number: pr.number,
24-
})
22+
let page = 1
23+
let commits = []
24+
while (true) {
25+
const response = await octokit.pulls.listCommits({
26+
owner: repo.owner.login,
27+
repo: repo.name,
28+
pull_number: pr.number,
29+
per_page: 100,
30+
page: page
31+
})
32+
33+
console.log(`Got ${response.data.length} commits at page ${page}`)
34+
commits = commits.concat(response.data)
2535

26-
let commits = commitsListed.data
36+
// has next?
37+
const linkHeader = response.headers.link
38+
if (!linkHeader || !linkHeader.includes('rel="next"')) {
39+
break
40+
}
41+
page++
42+
}
2743

2844
if (filterOutPattern) {
2945
const regex = new RegExp(filterOutPattern, filterOutFlags)
@@ -32,7 +48,14 @@ async function main() {
3248
})
3349
}
3450

35-
core.setOutput('commits', JSON.stringify(commits))
51+
const jsondata = JSON.stringify(commits)
52+
53+
core.setOutput('commits', jsondata)
54+
55+
if (outfile) {
56+
fs.writeFileSync(outfile, jsondata)
57+
console.log(`save json data to file:${outfile}.`)
58+
}
3659
} catch (error) {
3760
core.setFailed(error.message)
3861
}

0 commit comments

Comments
 (0)