Skip to content

Commit 0cd3373

Browse files
committed
fix bugs
fix
1 parent 6f369f6 commit 0cd3373

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
lines changed

.github/workflows/diff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v2
12+
- uses: actions/checkout@v2
13+
- run: git fetch --prune --unshallow
1414
- name: Diff
1515
id: diff
1616
uses: ./

dist/index.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,33 @@ const core = __webpack_require__(470)
961961
const exec = __webpack_require__(986)
962962

963963
async function run() {
964-
const command = 'changelog=$(git log $(git tag --sort version:refname | tail -n 2 | head -n 1)..$(git tag --sort version:refname | tail -n 1) --merges --reverse --pretty=format:"* %b")'
965-
console.log(command)
966-
967964
let output = ''
968-
969965
const options = {};
970966
options.listeners = {
971-
stdout: (data) => {
972-
output += data.toString();
967+
stdout: (data) => {
968+
output += data.toString();
969+
}
973970
}
971+
972+
const tag_command = 'git tag --sort version:refname'
973+
console.log(tag_command)
974+
await exec.exec(tag_command, [], options).catch(error => {
975+
core.setFailed(error.message)
976+
})
977+
978+
const tags = output.split('\n').filter(Boolean)
979+
console.log(tags)
980+
981+
output = ''
982+
983+
if (tags.length < 2) {
984+
core.setFailed("need more than 2 tags.")
985+
return
974986
}
975987

988+
const command = `git log ${tags[tags.length - 2]}..${tags[tags.length - 1]} --merges --reverse --pretty=format:"* %b"`
989+
console.log(command)
990+
976991
await exec.exec(command, [], options).catch(error => {
977992
core.setFailed(error.message)
978993
})
@@ -985,7 +1000,7 @@ async function run() {
9851000

9861001
console.log(output)
9871002

988-
const setoutput_command = `echo "::set-output name=changelog::${output}"`
1003+
const setoutput_command = `echo "::set-output name=diff::${output}"`
9891004
exec.exec(setoutput_command).catch(error => {
9901005
core.setFailed(error.message)
9911006
})

index.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,33 @@ const core = require('@actions/core')
22
const exec = require('@actions/exec')
33

44
async function run() {
5-
const command = 'changelog=$(git log $(git tag --sort version:refname | tail -n 2 | head -n 1)..$(git tag --sort version:refname | tail -n 1) --merges --reverse --pretty=format:"* %b")'
6-
console.log(command)
7-
85
let output = ''
9-
106
const options = {};
117
options.listeners = {
12-
stdout: (data) => {
13-
output += data.toString();
8+
stdout: (data) => {
9+
output += data.toString();
10+
}
1411
}
12+
13+
const tag_command = 'git tag --sort version:refname'
14+
console.log(tag_command)
15+
await exec.exec(tag_command, [], options).catch(error => {
16+
core.setFailed(error.message)
17+
})
18+
19+
const tags = output.split('\n').filter(Boolean)
20+
console.log(tags)
21+
22+
output = ''
23+
24+
if (tags.length < 2) {
25+
core.setFailed("need more than 2 tags.")
26+
return
1527
}
1628

29+
const command = `git log ${tags[tags.length - 2]}..${tags[tags.length - 1]} --merges --reverse --pretty=format:"* %b"`
30+
console.log(command)
31+
1732
await exec.exec(command, [], options).catch(error => {
1833
core.setFailed(error.message)
1934
})

0 commit comments

Comments
 (0)