From f1589cac6a9966dac4471516f8a6648d3c9ec858 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 4 May 2024 16:40:59 +0200 Subject: [PATCH 1/2] feat: uses 2 dots compare syntax for push diff --- dist/post_run/index.js | 5 ++--- dist/run/index.js | 5 ++--- src/run.ts | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index b6746c4c53..257c21b5c5 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -89221,11 +89221,10 @@ async function fetchPushPatch(ctx) { const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); let patch; try { - const patchResp = await octokit.rest.repos.compareCommits({ + const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({ owner: ctx.repo.owner, repo: ctx.repo.repo, - base: ctx.payload.before, - head: ctx.payload.after, + basehead: `${ctx.payload.before}..${ctx.payload.after}`, mediaType: { format: `diff`, }, diff --git a/dist/run/index.js b/dist/run/index.js index 278dc9a2c6..111a65705c 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -89221,11 +89221,10 @@ async function fetchPushPatch(ctx) { const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); let patch; try { - const patchResp = await octokit.rest.repos.compareCommits({ + const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({ owner: ctx.repo.owner, repo: ctx.repo.repo, - base: ctx.payload.before, - head: ctx.payload.after, + basehead: `${ctx.payload.before}..${ctx.payload.after}`, mediaType: { format: `diff`, }, diff --git a/src/run.ts b/src/run.ts index db8cf53a50..2d5d3a2ae2 100644 --- a/src/run.ts +++ b/src/run.ts @@ -104,11 +104,10 @@ async function fetchPushPatch(ctx: Context): Promise { let patch: string try { - const patchResp = await octokit.rest.repos.compareCommits({ + const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({ owner: ctx.repo.owner, repo: ctx.repo.repo, - base: ctx.payload.before, - head: ctx.payload.after, + basehead: `${ctx.payload.before}..${ctx.payload.after}`, mediaType: { format: `diff`, }, From 562d03e05b79825d756e909a8ab98047771589fa Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 4 May 2024 16:41:41 +0200 Subject: [PATCH 2/2] doc: add detailled only-new-issues explanation --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b05f02e823..e89250977d 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,6 @@ with: Show only new issues. -If you are using `merge_group` event (merge queue) you should add the option `fetch-depth: 0` to `actions/checkout` step. - The default value is `false`. ```yml @@ -148,6 +146,11 @@ with: # ... ``` +* `pull_request` and `pull_request_target`: the action gets the diff of the PR content from the [GitHub API](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) and use it with `--new-from-patch`. +* `push`: the action gets the diff of the push content (difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and use it with `--new-from-patch`. +* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git). + You should add the option `fetch-depth: 0` to `actions/checkout` step. + ### `working-directory` (optional)