Skip to content

Commit 8ae67e8

Browse files
committed
✨ Fetch Fork Repos
1 parent 2c986c7 commit 8ae67e8

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

dist/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32345,8 +32345,6 @@ const fs = __nccwpck_require__(7147);
3234532345

3234632346
async function run() {
3234732347
try {
32348-
const baseBranch = core.getInput("base");
32349-
const headBranch = core.getInput("head");
3235032348
const freshSnapshot = core.getInput("fresh-shapshots")==='true';
3235132349
const includeFuzzTests = core.getInput('include-fuzz-tests')==='true';
3235232350
const includeNewContracts = core.getInput('include-new-contracts')==='true';
@@ -32358,13 +32356,19 @@ async function run() {
3235832356
const genCommit = context.payload.pull_request.head.sha;
3235932357
const comCommit = context.payload.pull_request.base.sha;
3236032358

32359+
const headRepoFullName = context.payload.pull_request.head.repo.full_name;
32360+
const headBranch = context.payload.pull_request.head.ref;
32361+
32362+
const baseRepoFullName = context.payload.pull_request.base.repo.full_name;
32363+
const baseBranch = context.payload.pull_request.base.ref;
32364+
3236132365
if (freshSnapshot) {
3236232366
core.startGroup(`Generating the .gas-snapshot file from "${headBranch}"`);
32363-
await generateGasSnapshot(headBranch, ".gas-snapshot.pr");
32367+
await generateGasSnapshot(headRepoFullName, headBranch, ".gas-snapshot.pr");
3236432368
core.endGroup()
3236532369

3236632370
core.startGroup(`Generating the .gas-snapshot file from "${baseBranch}"`);
32367-
await generateGasSnapshot(baseBranch, ".gas-snapshot.base");
32371+
await generateGasSnapshot(baseRepoFullName, baseBranch, ".gas-snapshot.base");
3236832372
core.endGroup()
3236932373

3237032374
} else {
@@ -32420,8 +32424,10 @@ async function getGitFileContent(octokit, owner, repo, ref, filePath) {
3242032424
}
3242132425
}
3242232426

32423-
async function generateGasSnapshot(refBranch, fileName) {
32424-
await exec.exec('git', ['checkout', refBranch])
32427+
async function generateGasSnapshot(repoFullName, branchName, fileName) {
32428+
await exec.exec('git', ['fetch', `https://github.com/${repoFullName}`, `${branchName}`]);
32429+
await exec.exec('git', ['checkout', '-b', branchName, `FETCH_HEAD`]);
32430+
3242532431
const options = {
3242632432
ignoreReturnCode: true,
3242732433
silent: true

src/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const fs = require('fs');
55

66
async function run() {
77
try {
8-
const baseBranch = core.getInput("base");
9-
const headBranch = core.getInput("head");
108
const freshSnapshot = core.getInput("fresh-shapshots")==='true';
119
const includeFuzzTests = core.getInput('include-fuzz-tests')==='true';
1210
const includeNewContracts = core.getInput('include-new-contracts')==='true';
@@ -18,13 +16,19 @@ async function run() {
1816
const genCommit = context.payload.pull_request.head.sha;
1917
const comCommit = context.payload.pull_request.base.sha;
2018

19+
const headRepoFullName = context.payload.pull_request.head.repo.full_name;
20+
const headBranch = context.payload.pull_request.head.ref;
21+
22+
const baseRepoFullName = context.payload.pull_request.base.repo.full_name;
23+
const baseBranch = context.payload.pull_request.base.ref;
24+
2125
if (freshSnapshot) {
2226
core.startGroup(`Generating the .gas-snapshot file from "${headBranch}"`);
23-
await generateGasSnapshot(headBranch, ".gas-snapshot.pr");
27+
await generateGasSnapshot(headRepoFullName, headBranch, ".gas-snapshot.pr");
2428
core.endGroup()
2529

2630
core.startGroup(`Generating the .gas-snapshot file from "${baseBranch}"`);
27-
await generateGasSnapshot(baseBranch, ".gas-snapshot.base");
31+
await generateGasSnapshot(baseRepoFullName, baseBranch, ".gas-snapshot.base");
2832
core.endGroup()
2933

3034
} else {
@@ -80,8 +84,10 @@ async function getGitFileContent(octokit, owner, repo, ref, filePath) {
8084
}
8185
}
8286

83-
async function generateGasSnapshot(refBranch, fileName) {
84-
await exec.exec('git', ['checkout', refBranch])
87+
async function generateGasSnapshot(repoFullName, branchName, fileName) {
88+
await exec.exec('git', ['fetch', `https://github.com/${repoFullName}`, `${branchName}`]);
89+
await exec.exec('git', ['checkout', '-b', branchName, `FETCH_HEAD`]);
90+
8591
const options = {
8692
ignoreReturnCode: true,
8793
silent: true

0 commit comments

Comments
 (0)