Files
react-native/.github
emily8rown e7f56182d6 Fix JS API breaking change detection to compare against merge base (#54819)
Summary:
Updates the `diff-js-api-breaking-changes` action to compare the PR's changes against the merge base (where the branch diverged from main) instead of the current tip of main.

### Problem
The previous implementation compared the current state of `main` to the PR head. This could produce false positive results when main had new commits to reactNativeApi.d.ts reporting breaking changes from main as if they were introduced by the PR.

### Solution
- Calculate the merge base between the PR head and `origin/main`
- Compare the API snapshot at the merge base to the snapshot at the PR head

## Changelog:

[GENERAL] [FIXED] - Updates the `diff-js-api-breaking-changes` action to compare the PR's changes against the merge base (where the branch diverged from main) instead of the current tip of main.

Pull Request resolved: https://github.com/facebook/react-native/pull/54819

Test Plan:
(outputs shown for https://github.com/facebook/react-native/pull/54815)
Tested locally on branch that previously got false positive:
Mirror old approach:
```
mkdir -p /tmp/api-diff-old
git show origin/main:packages/react-native/ReactNativeApi.d.ts > /tmp/api-diff-old/before.d.ts
git show HEAD:packages/react-native/ReactNativeApi.d.ts > /tmp/api-diff-old/after.d.ts
node ./scripts/js-api/diff-api-snapshot /tmp/api-diff-old/before.d.ts /tmp/api-diff-old/after.d.ts
```
output:
```
{
  "result": "BREAKING",
  "changedApis": [
    "ActivityIndicatorProps",
    "Animated",
    "DrawerLayoutAndroidProps",
    "FlatList",
    "FlatListProps",
    "ImageBackground",
    "ImageBackgroundProps",
    "ImageProps",
    "ImagePropsBase",
    "KeyDownEvent",
    "KeyEvent",
    "KeyUpEvent",
    "KeyboardAvoidingView",
    "KeyboardAvoidingViewProps",
    "ModalProps",
    "PressableProps",
    "ProgressBarAndroidProps",
    "RefreshControl",
    "RefreshControlProps",
    "ScrollViewProps",
    "SectionList",
    "SectionListProps",
    "SwitchProps",
    "TextInputProps",
    "ViewProps",
    "VirtualizedListProps",
    "VirtualizedSectionListProps"
  ]
}
```
Mirror new approach:
```
git fetch origin main
MERGE_BASE=$(git merge-base HEAD origin/main)
echo "Merge base: $MERGE_BASE"
mkdir -p /tmp/api-diff
git show $MERGE_BASE:packages/react-native/ReactNativeApi.d.ts > /tmp/api-diff/before.d.ts
git show HEAD:packages/react-native/ReactNativeApi.d.ts > /tmp/api-diff/after.d.ts
node ./scripts/js-api/diff-api-snapshot /tmp/api-diff/before.d.ts /tmp/api-diff/after.d.ts
```
output:
```
{
  "result": "NON_BREAKING",
  "changedApis": []
}
```

Reviewed By: huntie

Differential Revision: D88654826

Pulled By: emily8rown

fbshipit-source-id: 5dc2e295d7d527899b5cb6a643c4878aeebf7f0b
2025-12-10 04:55:52 -08:00
..
2021-01-14 14:58:10 -08:00