generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try cloning without actions/checkout
- Loading branch information
Showing
7 changed files
with
206 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as core from '@actions/core' | ||
import * as lib from 'simple-git' | ||
|
||
export class Git { | ||
private client: lib.SimpleGit | ||
|
||
constructor() { | ||
const basicCredential = Buffer.from( | ||
`x-access-token:${core.getInput('token')}`, | ||
'utf8' | ||
).toString('base64') | ||
const authorizationHeader = `AUTHORIZATION: basic ${basicCredential}` | ||
core.setSecret(basicCredential) | ||
|
||
this.client = lib.simpleGit('.', { | ||
trimmed: true, | ||
config: [`http.extraheader=${authorizationHeader}`] | ||
}) | ||
} | ||
|
||
/** | ||
* Clones the repository from which this workflow was triggered. | ||
* | ||
* @param repo The repository to clone in the format "<owner>/<name>" | ||
* @param headRef The single branch to clone, which should correspond to the | ||
* head ref of the pull request that triggered this workflow. This is | ||
* required for efficiency. | ||
* @param targetDirectory The directory in which to clone the repository. | ||
*/ | ||
async clone( | ||
repo: string, | ||
headRef: string, | ||
targetDirectory = '.' | ||
): Promise<void> { | ||
core.info(`Cloning ${repo} with the single branch "${headRef}"`) | ||
|
||
await this.client.clone(`https://github.com/${repo}`, targetDirectory, [ | ||
`--branch=${headRef}`, | ||
'--filter=tree:0', | ||
'--no-tags', | ||
'--single-branch' | ||
]) | ||
} | ||
|
||
/** | ||
* Retrieves the diff of the pull request that triggered this workflow which we | ||
* will use for evaluation. | ||
* | ||
* @param baseRef The base branch relative to which we should produce a diff. This method assumes | ||
* that the head ref containing the changes has already been fetched. | ||
* @returns The diff of the given pull request or `undefined` if we failed to retrieve it. | ||
*/ | ||
async diff(baseRef: string): Promise<string | undefined> { | ||
core.debug(`Fetching base ref "${baseRef}"`) | ||
await this.client.fetch([ | ||
'origin', | ||
`+${baseRef}:${baseRef}`, | ||
`--filter=tree:0`, | ||
'--no-tags', | ||
'--prune', | ||
'--no-recurse-submodules' | ||
]) | ||
|
||
const diffArgs = ['--merge-base', baseRef].concat( | ||
core.getInput('git-diff-options').split(/\s+/) | ||
) | ||
core.info(`Retrieving diff with \`git diff ${diffArgs.join(' ')}\``) | ||
return this.client.diff(diffArgs) | ||
} | ||
} |
Oops, something went wrong.