forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MetaMask#19310 from MetaMask/Version-v10.32.0
Version v10.32.0 RC
- Loading branch information
Showing
378 changed files
with
22,255 additions
and
15,489 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
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
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,177 @@ | ||
import * as core from '@actions/core'; | ||
import { context, getOctokit } from '@actions/github'; | ||
import { GitHub } from '@actions/github/lib/utils'; | ||
|
||
main().catch((error: Error): void => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|
||
async function main(): Promise<void> { | ||
const token = process.env.GITHUB_TOKEN; | ||
|
||
if (!token) { | ||
core.setFailed('GITHUB_TOKEN not found'); | ||
process.exit(1); | ||
} | ||
|
||
const octokit = getOctokit(token); | ||
|
||
const headRef = context.payload.pull_request?.head.ref || ''; | ||
|
||
let issueNumber = await getIssueNumberFromPullRequestBody(); | ||
if (issueNumber === "") { | ||
bailIfIsBranchNameInvalid(headRef); | ||
bailIfIsNotFeatureBranch(headRef); | ||
issueNumber = getIssueNumberFromBranchName(headRef); | ||
} | ||
|
||
if (Number(issueNumber) === 0) { | ||
process.exit(0); | ||
} | ||
|
||
await updateLabels(octokit, issueNumber); | ||
} | ||
|
||
async function getIssueNumberFromPullRequestBody(): Promise<string> { | ||
console.log("Checking if the PR's body references an issue..."); | ||
|
||
let ISSUE_LINK_IN_PR_DESCRIPTION_REGEX = | ||
/(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s#\d+/gi; | ||
|
||
const prBody = await getPullRequestBody(); | ||
|
||
let matches = prBody.match(ISSUE_LINK_IN_PR_DESCRIPTION_REGEX); | ||
if (!matches || matches?.length === 0) { | ||
console.log( | ||
'No direct link can be drawn between the PR and an issue from the PR body because no issue number was referenced.', | ||
); | ||
return ""; | ||
} | ||
|
||
if (matches?.length > 1) { | ||
console.log( | ||
'No direct link can be drawn between the PR and an issue from the PR body because more than one issue number was referenced.', | ||
); | ||
return ""; | ||
} | ||
|
||
const ISSUE_NUMBER_REGEX = /\d+/; | ||
const issueNumber = matches[0].match(ISSUE_NUMBER_REGEX)?.[0] || ''; | ||
|
||
console.log(`Found issue number ${issueNumber} in PR body.`); | ||
|
||
return issueNumber; | ||
} | ||
|
||
async function getPullRequestBody(): Promise<string> { | ||
if (context.eventName !== 'pull_request') { | ||
console.log('This action should only run on pull_request events.'); | ||
process.exit(1); | ||
} | ||
|
||
const prBody = context.payload.pull_request?.body || ''; | ||
return prBody; | ||
} | ||
|
||
function bailIfIsBranchNameInvalid(branchName: string): void { | ||
const BRANCH_REGEX = | ||
/^(main|develop|(ci|chore|docs|feat|feature|fix|perf|refactor|revert|style)\/\d*(?:[-](?![-])\w*)*|Version-v\d+\.\d+\.\d+)$/; | ||
const isValidBranchName = new RegExp(BRANCH_REGEX).test(branchName); | ||
|
||
if (!isValidBranchName) { | ||
console.log('This branch name does not follow the convention.'); | ||
console.log( | ||
'Here are some example branch names that are accepted: "fix/123-description", "feat/123-longer-description", "feature/123", "main", "develop", "Version-v10.24.2".', | ||
); | ||
console.log( | ||
'No issue could be linked to this PR, so no labels were copied', | ||
); | ||
|
||
process.exit(0); | ||
} | ||
} | ||
|
||
function bailIfIsNotFeatureBranch(branchName: string): void { | ||
if ( | ||
branchName === 'main' || | ||
branchName === 'develop' || | ||
branchName.startsWith('Version-v') | ||
) { | ||
console.log(`${branchName} is not a feature branch.`); | ||
console.log( | ||
'No issue could be linked to this PR, so no labels were copied', | ||
); | ||
process.exit(0); | ||
} | ||
} | ||
|
||
async function updateLabels(octokit: InstanceType<typeof GitHub>, issueNumber: string): Promise<void> { | ||
interface ILabel { | ||
name: string; | ||
}; | ||
|
||
const owner = context.repo.owner; | ||
const repo = context.repo.repo; | ||
|
||
const issue = await octokit.rest.issues.get({ | ||
owner: owner, | ||
repo: repo, | ||
issue_number: Number(issueNumber), | ||
}); | ||
|
||
const getNameFromLabel = (label: ILabel): string => label.name | ||
|
||
const issueLabels = issue.data.labels.map(label => getNameFromLabel(label as ILabel)); | ||
|
||
const prNumber = context.payload.number; | ||
|
||
const pr = await octokit.rest.issues.get({ | ||
owner: owner, | ||
repo: repo, | ||
issue_number: prNumber, | ||
}); | ||
|
||
const startingPRLabels = pr.data.labels.map(label => getNameFromLabel(label as ILabel)); | ||
|
||
const dedupedFinalPRLabels = [ | ||
...new Set([...startingPRLabels, ...issueLabels]), | ||
]; | ||
|
||
const hasIssueAdditionalLabels = !sortedArrayEqual( | ||
startingPRLabels, | ||
dedupedFinalPRLabels, | ||
); | ||
if (hasIssueAdditionalLabels) { | ||
await octokit.rest.issues.update({ | ||
owner, | ||
repo, | ||
issue_number: prNumber, | ||
labels: dedupedFinalPRLabels, | ||
}); | ||
} | ||
} | ||
|
||
function getIssueNumberFromBranchName(branchName: string): string { | ||
console.log('Checking if the branch name references an issue...'); | ||
|
||
let issueNumber: string; | ||
if (branchName.split('/').length > 1) { | ||
issueNumber = branchName.split('/')[1].split('-')[0]; | ||
} else { | ||
issueNumber = branchName.split('-')[0]; | ||
} | ||
|
||
console.log(`Found issue number ${issueNumber} in branch name.`); | ||
|
||
return issueNumber; | ||
} | ||
|
||
function sortedArrayEqual(array1: string[], array2: string[]): boolean { | ||
const lengthsAreEqual = array1.length === array2.length; | ||
const everyElementMatchesByIndex = array1.every( | ||
(value: string, index: number): boolean => value === array2[index], | ||
); | ||
|
||
return lengthsAreEqual && everyElementMatchesByIndex; | ||
} |
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,27 @@ | ||
name: Label PR | ||
|
||
on: | ||
pull_request: | ||
types: [assigned, opened, edited, synchronize, reopened] | ||
|
||
jobs: | ||
label-pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Install Yarn | ||
run: npm install -g yarn | ||
|
||
- name: Install dependencies | ||
run: yarn |
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
# improved-yarn-audit advisory exclusions | ||
GHSA-257v-vj4p-3w2h | ||
|
||
# yarn berry's `yarn npm audit` script reports the following vulnerability but | ||
# it is a false positive. The offending version of 'ws' that is installed is | ||
# 7.1.1 and is included only via remote-redux-devtools which is a devDependency | ||
GHSA-6fc8-4gx4-v693 | ||
|
||
# request library is subject to SSRF. | ||
# addressed by temporary patch in .yarn/patches/request-npm-2.88.2-f4a57c72c4.patch | ||
GHSA-p8p7-x288-28g6 |
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
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
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
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,12 @@ | ||
diff --git a/lib/index.js b/lib/index.js | ||
index c991f62dc64553502e9911a7f21e77e008d7f438..e503c7494d21b13df85b10e1657b2af8ca4d964f 100644 | ||
--- a/lib/index.js | ||
+++ b/lib/index.js | ||
@@ -222,7 +222,6 @@ var _transform = require("./transform"); | ||
var _transformFile = require("./transform-file"); | ||
var _transformAst = require("./transform-ast"); | ||
var _parse = require("./parse"); | ||
-var thisFile = require("./index"); | ||
const version = "7.21.5"; | ||
exports.version = version; | ||
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]); |
Oops, something went wrong.