feat: uses 2 dots compare syntax for push diff (#1030)

This commit is contained in:
Ludovic Fernandez 2024-05-04 16:54:30 +02:00 committed by GitHub
parent 046435d14c
commit ecb32920c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 11 deletions

View File

@ -137,8 +137,6 @@ with:
Show only new issues. 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`. The default value is `false`.
```yml ```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` ### `working-directory`
(optional) (optional)

5
dist/post_run/index.js generated vendored
View File

@ -89221,11 +89221,10 @@ async function fetchPushPatch(ctx) {
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }));
let patch; let patch;
try { try {
const patchResp = await octokit.rest.repos.compareCommits({ const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner, owner: ctx.repo.owner,
repo: ctx.repo.repo, repo: ctx.repo.repo,
base: ctx.payload.before, basehead: `${ctx.payload.before}..${ctx.payload.after}`,
head: ctx.payload.after,
mediaType: { mediaType: {
format: `diff`, format: `diff`,
}, },

5
dist/run/index.js generated vendored
View File

@ -89221,11 +89221,10 @@ async function fetchPushPatch(ctx) {
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }));
let patch; let patch;
try { try {
const patchResp = await octokit.rest.repos.compareCommits({ const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner, owner: ctx.repo.owner,
repo: ctx.repo.repo, repo: ctx.repo.repo,
base: ctx.payload.before, basehead: `${ctx.payload.before}..${ctx.payload.after}`,
head: ctx.payload.after,
mediaType: { mediaType: {
format: `diff`, format: `diff`,
}, },

View File

@ -104,11 +104,10 @@ async function fetchPushPatch(ctx: Context): Promise<string> {
let patch: string let patch: string
try { try {
const patchResp = await octokit.rest.repos.compareCommits({ const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner, owner: ctx.repo.owner,
repo: ctx.repo.repo, repo: ctx.repo.repo,
base: ctx.payload.before, basehead: `${ctx.payload.before}..${ctx.payload.after}`,
head: ctx.payload.after,
mediaType: { mediaType: {
format: `diff`, format: `diff`,
}, },