Skip to content

Commit

Permalink
Update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
obrassard committed Mar 15, 2024
1 parent 7b9ad7e commit 6c7269d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 63 deletions.
50 changes: 8 additions & 42 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,9 @@ async function getPullRequestNumbersFromCommits(
fromTag: string,
toTag: string
) {
const commitLogs = await runCommand('git', [
'--no-pager',
'log',
`${fromTag}..${toTag}`,
'--oneline',
'--grep="Merge pull request #"'
])

core.info(commitLogs)
const commitLogs = await runCommand(
`/bin/bash -c "git --no-pager log ${fromTag}..${toTag} --oneline | grep 'Merge pull request #'"`
)

const regex = /#\d+/g
const pullRequestNumbers =
Expand Down
19 changes: 8 additions & 11 deletions src/run-command.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import * as core from '@actions/core'
import { ExecOptions, exec } from '@actions/exec'

export function runCommand(command: string, args: string[]): Promise<string> {
export function runCommand(command: string, args?: string[]): Promise<string> {
return new Promise(async (resolve, reject) => {
let output = ''
let errorOutput = ''
const options: ExecOptions = {}
options.listeners = {
stdout: (data: Buffer) => {
const str = data.toString()
core.info(str)
output += str
stdline: (data: string) => {
output += data + '\n'
},
stderr: (data: Buffer) => {
errorOutput += data.toString()
errline: (data: string) => {
errorOutput += data + '\n'
}
}

await exec(command, args, options)
if (errorOutput) {
const code = await exec(command, args, options)

if (code !== 0) {
reject(errorOutput)
} else {
core.info(output)
resolve(output)
}
})
Expand Down

0 comments on commit 6c7269d

Please sign in to comment.