From cac72c2965e5f532c61d109af763127e10033b58 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:39:59 +0100 Subject: [PATCH 01/12] add workflow --- .github/workflows/update-prs.js | 22 ++++++++++++++++++++++ .github/workflows/update-prs.yml | 14 ++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/update-prs.js create mode 100644 .github/workflows/update-prs.yml diff --git a/.github/workflows/update-prs.js b/.github/workflows/update-prs.js new file mode 100644 index 00000000..7e8225aa --- /dev/null +++ b/.github/workflows/update-prs.js @@ -0,0 +1,22 @@ +const owner = 'your_owner'; +const repo = 'your_repo'; +const accessToken = 'your_access_token'; + +const apiUrl = `https://api.github.com/repos/${owner}/${repo}/pulls`; + +try { + const response = await fetch(apiUrl, { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); + + if (!response.ok) { + throw new Error(`Failed to fetch pull requests: ${response.statusText}`); + } + + const data = await response.json(); + console.log(data); +} catch (error) { + console.error(error); +} \ No newline at end of file diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml new file mode 100644 index 00000000..da5062b1 --- /dev/null +++ b/.github/workflows/update-prs.yml @@ -0,0 +1,14 @@ +on: + push: + + +jobs: + trigger-pr-update: + runs-on: ubuntu-latest + + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + + - name: Run JavaScript file + run: node ./update-prs.js From 1419d5419c23d79cd76b6ccbdc43826dcfcd7d19 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:46:54 +0100 Subject: [PATCH 02/12] add github-script --- .github/workflows/update-prs.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index da5062b1..7df927f5 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -7,8 +7,15 @@ jobs: runs-on: ubuntu-latest steps: - - name: Setup Node.js - uses: actions/setup-node@v3 - - - name: Run JavaScript file - run: node ./update-prs.js + - uses: actions/github-script@v7 + with: + script: | + // Get a list of all issues created by the PR opener + // See: https://octokit.github.io/rest.js/#pagination + const creator = context.payload.sender.login + const prs = github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo + }); + + console.log(prs) \ No newline at end of file From fa32b4696be5492f3cd945368b4847479e3d96dc Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:50:03 +0100 Subject: [PATCH 03/12] add github-script --- .github/workflows/update-prs.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 7df927f5..7a5fbdca 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -13,9 +13,12 @@ jobs: // Get a list of all issues created by the PR opener // See: https://octokit.github.io/rest.js/#pagination const creator = context.payload.sender.login - const prs = github.rest.pulls.get({ + const prs = gawait github.rest.request('GET /repos/{owner}/{repo}/pulls', { owner: context.repo.owner, repo: context.repo.repo - }); + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } + }) console.log(prs) \ No newline at end of file From 15c989810dce4f467bc22c6fd1171dd83ae3eb81 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:50:35 +0100 Subject: [PATCH 04/12] add github-script --- .github/workflows/update-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 7a5fbdca..63ddbbc8 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -13,7 +13,7 @@ jobs: // Get a list of all issues created by the PR opener // See: https://octokit.github.io/rest.js/#pagination const creator = context.payload.sender.login - const prs = gawait github.rest.request('GET /repos/{owner}/{repo}/pulls', { + const prs = await github.rest.request('GET /repos/{owner}/{repo}/pulls', { owner: context.repo.owner, repo: context.repo.repo headers: { From db7396ba95c98a9a1f617a1e1fd55acbbf70b415 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:51:03 +0100 Subject: [PATCH 05/12] add github-script --- .github/workflows/update-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 63ddbbc8..ec3c981f 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -15,7 +15,7 @@ jobs: const creator = context.payload.sender.login const prs = await github.rest.request('GET /repos/{owner}/{repo}/pulls', { owner: context.repo.owner, - repo: context.repo.repo + repo: context.repo.repo, headers: { 'X-GitHub-Api-Version': '2022-11-28' } From e95477fe2c9a8094b533b21ade3d03d0c5b80425 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:52:52 +0100 Subject: [PATCH 06/12] add github-script --- .github/workflows/update-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index ec3c981f..1c91ac4c 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -13,7 +13,7 @@ jobs: // Get a list of all issues created by the PR opener // See: https://octokit.github.io/rest.js/#pagination const creator = context.payload.sender.login - const prs = await github.rest.request('GET /repos/{owner}/{repo}/pulls', { + const prs = await github.request('GET /repos/{owner}/{repo}/pulls', { owner: context.repo.owner, repo: context.repo.repo, headers: { From 96621d9e86ed0dea264b16e91ade0a98cf3bf4df Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:56:19 +0100 Subject: [PATCH 07/12] add github-script --- .github/workflows/update-prs.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 1c91ac4c..7e2d1877 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -20,5 +20,17 @@ jobs: 'X-GitHub-Api-Version': '2022-11-28' } }) - - console.log(prs) \ No newline at end of file + + console.log(prs); + for (const pr of prs.data) { + await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + base: 'develop', + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } + }) + break; + } From 86983595b06ceb436b097021f760437d207a6b2a Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:57:24 +0100 Subject: [PATCH 08/12] update permissions --- .github/workflows/update-prs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 7e2d1877..94ec6e3d 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -1,6 +1,8 @@ on: push: +permissions: + pull-requests: write jobs: trigger-pr-update: From d0b18060fc52ab8023e5df09703e8d4b2577a5cb Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 19:59:57 +0100 Subject: [PATCH 09/12] update github-script --- .github/workflows/update-prs.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 94ec6e3d..52fad32b 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -23,8 +23,9 @@ jobs: } }) - console.log(prs); for (const pr of prs.data) { + if (pr.state !== 'open') continue; + console.log("Refreshing PR diff for #" + pr.number + " (" + pr.title + ")"); await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', { owner: context.repo.owner, repo: context.repo.repo, @@ -34,5 +35,13 @@ jobs: 'X-GitHub-Api-Version': '2022-11-28' } }) - break; + await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + base: 'main', + headers: { + 'X-GitHub-Api-Version': '2022-11-28' + } + }) } From 9ea160ec93c6c54b91c2d496a5f51f73c7bd1b9a Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 20:01:49 +0100 Subject: [PATCH 10/12] trigger on push to main --- .github/workflows/update-prs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml index 52fad32b..deaa4199 100644 --- a/.github/workflows/update-prs.yml +++ b/.github/workflows/update-prs.yml @@ -1,5 +1,8 @@ +name: Refresh PRs on: push: + branches: + - main permissions: pull-requests: write From 8dec545b5ee8b4ea23e963b2b49e142622b92dd8 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 20:04:58 +0100 Subject: [PATCH 11/12] remove js file --- .github/workflows/update-prs.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/update-prs.js diff --git a/.github/workflows/update-prs.js b/.github/workflows/update-prs.js deleted file mode 100644 index 7e8225aa..00000000 --- a/.github/workflows/update-prs.js +++ /dev/null @@ -1,22 +0,0 @@ -const owner = 'your_owner'; -const repo = 'your_repo'; -const accessToken = 'your_access_token'; - -const apiUrl = `https://api.github.com/repos/${owner}/${repo}/pulls`; - -try { - const response = await fetch(apiUrl, { - headers: { - Authorization: `Bearer ${accessToken}`, - }, - }); - - if (!response.ok) { - throw new Error(`Failed to fetch pull requests: ${response.statusText}`); - } - - const data = await response.json(); - console.log(data); -} catch (error) { - console.error(error); -} \ No newline at end of file From ab54a05753c49dfac33b09e02420ea71c6a449e4 Mon Sep 17 00:00:00 2001 From: benStre Date: Wed, 17 Jan 2024 23:37:53 +0100 Subject: [PATCH 12/12] debug --- runtime/pointers.ts | 1 + runtime/storage.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/pointers.ts b/runtime/pointers.ts index 17d486bd..35017b0c 100644 --- a/runtime/pointers.ts +++ b/runtime/pointers.ts @@ -1506,6 +1506,7 @@ export class Pointer extends Ref { // check read permissions pointer.assertEndpointCanRead(SCOPE?.sender) + return pointer; } diff --git a/runtime/storage.ts b/runtime/storage.ts index 43f71230..ce4c8f72 100644 --- a/runtime/storage.ts +++ b/runtime/storage.ts @@ -407,7 +407,6 @@ export class Storage { } public static setPointer(pointer:Pointer, listen_for_changes = true, location:StorageLocation|undefined = this.#primary_location, partialUpdateKey: unknown = NOT_EXISTING): Promise|boolean { - if (!pointer.value_initialized) { // logger.warn("pointer value " + pointer.idString() + " not available, cannot save in storage"); this.#storage_active_pointers.delete(pointer);