mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
chore(dangerfile): Auto-label pull requests opened against release branches (#32917)
Summary: ## Summary Update dangerfile in order auto-label pull requests opened against release branches Closes https://github.com/facebook/react-native/issues/32692 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Internal] [Added] - Auto-label pull requests opened against release branches Pull Request resolved: https://github.com/facebook/react-native/pull/32917 Test Plan: As I don't have admin rights to this repo I tested this script on [a PR in my fork](https://github.com/gabrieldonadel/react-native/pull/1) by running ``` yarn danger pr https://github.com/gabrieldonadel/react-native/pull/1 ``` https://user-images.githubusercontent.com/11707729/150026370-4cce7831-c4ee-4269-b6a8-646f965826c5.mov As you can see in the video once I run the script it automatically adds the label Reviewed By: lunaleaps Differential Revision: D33647174 Pulled By: yungsters fbshipit-source-id: a7e7cab458b4cb7ff2cf318c4df1e9fb5d91a9f7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0a5481924c
commit
43e07a4941
+17
-2
@@ -89,11 +89,26 @@ if (!includesChangelog) {
|
||||
|
||||
// Warns if the PR is opened against stable, as commits need to be cherry picked and tagged by a release maintainer.
|
||||
// Fails if the PR is opened against anything other than `main` or `-stable`.
|
||||
const isMergeRefMaster = danger.github.pr.base.ref === 'main';
|
||||
const isMergeRefMain = danger.github.pr.base.ref === 'main';
|
||||
const isMergeRefStable = danger.github.pr.base.ref.indexOf('-stable') !== -1;
|
||||
if (!isMergeRefMaster && !isMergeRefStable) {
|
||||
if (!isMergeRefMain && !isMergeRefStable) {
|
||||
const title = ':exclamation: Base Branch';
|
||||
const idea =
|
||||
'The base branch for this PR is something other than `main` or a `-stable` branch. [Are you sure you want to target something other than the `main` branch?](https://reactnative.dev/docs/contributing#pull-requests)';
|
||||
fail(`${title} - <i>${idea}</i>`);
|
||||
}
|
||||
|
||||
// If the PR is opened against stable should add `Pick Request` label
|
||||
if (isMergeRefStable) {
|
||||
const {owner, repo, number: issueNumber} = danger.github.thisPR;
|
||||
|
||||
danger.github.api.request(
|
||||
'POST /repos/{owner}/{repo}/issues/{issueNumber}/labels',
|
||||
{
|
||||
owner,
|
||||
repo,
|
||||
issueNumber,
|
||||
labels: ['Pick Request'],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user