From a7d52be255ed69564ffde59cf560ac8f4c03f09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9r=C3=A8?= Date: Sun, 31 Dec 2023 01:46:13 -0800 Subject: [PATCH] Try cloning without actions/checkout --- README.md | 11 ----------- badges/coverage.svg | 2 +- dist/index.js | 28 +++++++++------------------- src/initializer.ts | 34 +++++++++++----------------------- 4 files changed, 21 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index e4888ae..3ba42cd 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,6 @@ jobs: runs-on: ubuntu-latest steps: - # Perform a minimal checkout to set up this repository for the rest of the - # workflow. - # - # This step must be configured exactly as below: using different - # actions/checkout arguments is not supported. - - name: Checkout this repository - uses: actions/checkout@v4 - with: - filter: tree:0 - - # Run the estimation tool - name: Run sizeup # TODO: Replace the version below with your desired version. uses: lerebear/sizeup-action@v0.4.2 diff --git a/badges/coverage.svg b/badges/coverage.svg index d179b1d..24cd63a 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 63.23%Coverage63.23% \ No newline at end of file +Coverage: 61.87%Coverage61.87% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 8cef7fe..d372d6d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16402,27 +16402,17 @@ exports.pullRequestAuthorHasNotOptedIn = pullRequestAuthorHasNotOptedIn; */ async function fetchDiff(pull) { const git = (0, simple_git_1.simpleGit)('.', { trimmed: true }); - // let baseRefExists = false - // try { - // baseRefExists = !!(await git.raw('rev-parse', '--verify', pull.base.ref)) - // } catch (e) { - // core.error( - // `Error from 'git rev-parse --verfy ${pull.base.ref}': ${ - // (e as Error).message - // }` - // ) - // } - // if (!baseRefExists) { - // core.setFailed( - // `Could not find pull request base branch ${pull.base.ref}. ` + - // `Please make sure actions/checkout was used beforehand to fetch ${pull.base.ref}.` - // ) - // return - // } - core.debug(`Fetching base ref "${pull.base.ref}" and head ref "${pull.head.ref}"`); + core.debug(`Cloning just the base ref "${pull.base.ref}"`); + const cloneUrl = `https://${core.getInput('token')}@github.com/${github.context.repo.owner}/${github.context.repo.repo}`; + await git.clone(cloneUrl, '.', [ + `--branch=${pull.base.ref}`, + '--filter=tree:0', + '--no-tags', + '--single-branch' + ]); + core.debug(`Fetching head ref "${pull.head.ref}"`); await git.fetch([ 'origin', - `+${pull.base.ref}:${pull.base.ref}`, `+${pull.head.ref}:${pull.head.ref}`, `--filter=tree:0`, '--no-tags', diff --git a/src/initializer.ts b/src/initializer.ts index c4eb934..5880cb6 100644 --- a/src/initializer.ts +++ b/src/initializer.ts @@ -72,32 +72,20 @@ export async function fetchDiff( ): Promise { const git = simpleGit('.', { trimmed: true }) - // let baseRefExists = false - // try { - // baseRefExists = !!(await git.raw('rev-parse', '--verify', pull.base.ref)) - // } catch (e) { - // core.error( - // `Error from 'git rev-parse --verfy ${pull.base.ref}': ${ - // (e as Error).message - // }` - // ) - // } - - // if (!baseRefExists) { - // core.setFailed( - // `Could not find pull request base branch ${pull.base.ref}. ` + - // `Please make sure actions/checkout was used beforehand to fetch ${pull.base.ref}.` - // ) - // return - // } - - core.debug( - `Fetching base ref "${pull.base.ref}" and head ref "${pull.head.ref}"` - ) + core.debug(`Cloning just the base ref "${pull.base.ref}"`) + const cloneUrl = `https://${core.getInput('token')}@github.com/${ + github.context.repo.owner + }/${github.context.repo.repo}` + await git.clone(cloneUrl, '.', [ + `--branch=${pull.base.ref}`, + '--filter=tree:0', + '--no-tags', + '--single-branch' + ]) + core.debug(`Fetching head ref "${pull.head.ref}"`) await git.fetch([ 'origin', - `+${pull.base.ref}:${pull.base.ref}`, `+${pull.head.ref}:${pull.head.ref}`, `--filter=tree:0`, '--no-tags',