Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsflower: Make patches more reproducible between machines/developers #5407

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions tools/tsflower
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export * from './lib/typescript/src/index.js.flow';"
apply_patches()
{
for p in "${patch_dir}"/*.patch; do
if ! patch "${patch_opts[@]}" -p1 <"${p}"; then
if ! patch "${patch_opts[@]}" -p0 <"${p}"; then
echo >&2 "apply-patches: Failed at patch: ${p#"${rootdir}/"}"
return 1
fi
Expand All @@ -179,7 +179,7 @@ unapply_patches()
local i p
for (( i = ${#patches[@]} - 1; i >= 0; i-- )); do
p="${patches[i]}"
if ! patch "${patch_opts[@]}" -p1 -R <"${p}"; then
if ! patch "${patch_opts[@]}" -p0 -R <"${p}"; then
echo >&2 "unapply-patches: Failed at patch: ${p#"${rootdir}/"}"
return 1
fi
Expand All @@ -189,11 +189,35 @@ unapply_patches()
write_patches()
{
local commit_range="${1:-upstream..tsflower}"

rm -f "${patch_dir}"/*.patch
git -c diff.noprefix=false \

local format_patch_config=(
# Print the paths verbatim, without added a/ and b/ prefixes.
# This makes it a bit simpler to jump to the file when seeing
# the patch in the terminal. (Corresponds to passing `-p0` to
# `patch` and `git am` when consuming the patches.)
-c diff.noprefix=true

# Merge the context of hunks that nearly touch. (Can make
# diffs a bit more readable; more importantly, override user
# config with some consistent value for reproducibility.)
-c diff.interHunkContext=6
)
git "${format_patch_config[@]}" \
format-patch --quiet --zero-commit \
--no-thread --no-numbered --keep-subject \
-o "${patch_dir}" "${commit_range}"

# `git format-patch` writes the Git version number at the end.
# For reproducibility, normalize that to an arbitrary (realistic) value.
perl -i -0pe '
s< ^ # beginning of a line (with "m" flag below)
2 \. .* # a 2.x version number (in case a future 3.x
# actually makes a difference here)
\n\n \Z # end of line, blank line, end of file
><2.32.0\n\n>xm
' "${patch_dir}"/*.patch
}

check_consistent()
Expand Down Expand Up @@ -289,7 +313,7 @@ EOF
git commit -am 'tsflower: Revert patches'

git checkout --quiet -B "${branchname}"
git am --quiet --whitespace=nowarn --keep "${patch_dir}"/*.patch
git am --quiet --whitespace=nowarn -p0 --keep "${patch_dir}"/*.patch

if [ -z "${shortcut}" ]; then
git checkout --quiet "${basebranch}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Discussion with a reduced repro of the Prettier bug:
.../routers/lib/typescript/src/TabRouter.js.flow | 1 +
3 files changed, 4 insertions(+)

diff --git a/types/@react-navigation/core/lib/typescript/src/types.js.flow b/types/@react-navigation/core/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/core/lib/typescript/src/types.js.flow types/@react-navigation/core/lib/typescript/src/types.js.flow
index 086c12609..b6145283b 100644
--- a/types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/core/lib/typescript/src/types.js.flow
--- types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ types/@react-navigation/core/lib/typescript/src/types.js.flow
@@ -150,6 +150,7 @@ type NavigationHelpersCommon<
State: NavigationState<> = NavigationState<>,
> = {
Expand All @@ -24,10 +24,10 @@ index 086c12609..b6145283b 100644
navigate<RouteName: $Keys<ParamList>>(
...args: $FlowFixMe /* undefined extends ParamList[RouteName] ? [RouteName] | [RouteName, ParamList[RouteName]] : [RouteName, ParamList[RouteName]] */ /* tsflower-unimplemented: ConditionalType */
): void,
diff --git a/types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow b/types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
diff --git types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
index 179e34e09..3bd89b8ce 100644
--- a/types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
+++ b/types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
--- types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
+++ types/@react-navigation/routers/lib/typescript/src/StackRouter.js.flow
@@ -58,9 +58,11 @@ export type StackNavigationState<ParamList: ParamListBase> = NavigationState<Par
};

Expand All @@ -40,10 +40,10 @@ index 179e34e09..3bd89b8ce 100644
push<RouteName: $Keys<ParamList>>(
...args: $FlowFixMe /* undefined extends ParamList[RouteName] ? [RouteName] | [RouteName, ParamList[RouteName]] : [RouteName, ParamList[RouteName]] */ /* tsflower-unimplemented: ConditionalType */
): void,
diff --git a/types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow b/types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
diff --git types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
index fd281a865..4fa8ed1ca 100644
--- a/types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
+++ b/types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
--- types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
+++ types/@react-navigation/routers/lib/typescript/src/TabRouter.js.flow
@@ -41,6 +41,7 @@ export type TabNavigationState<ParamList: ParamListBase> = $Diff<
};

Expand All @@ -53,5 +53,5 @@ index fd281a865..4fa8ed1ca 100644
...args: $FlowFixMe /* undefined extends ParamList[RouteName] ? [RouteName] | [RouteName, ParamList[RouteName]] : [RouteName, ParamList[RouteName]] */ /* tsflower-unimplemented: ConditionalType */
): void,
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ mechanism.
types/react-native-safe-area-context/SafeArea.types.js.flow | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/types/react-native-safe-area-context/SafeArea.types.js.flow b/types/react-native-safe-area-context/SafeArea.types.js.flow
diff --git types/react-native-safe-area-context/SafeArea.types.js.flow types/react-native-safe-area-context/SafeArea.types.js.flow
index f3c41af41..e31ab1a65 100644
--- a/types/react-native-safe-area-context/SafeArea.types.js.flow
+++ b/types/react-native-safe-area-context/SafeArea.types.js.flow
--- types/react-native-safe-area-context/SafeArea.types.js.flow
+++ types/react-native-safe-area-context/SafeArea.types.js.flow
@@ -9,7 +9,6 @@ import type {
} from 'tsflower/subst/react-native';

Expand All @@ -37,5 +37,5 @@ index f3c41af41..e31ab1a65 100644
...
};
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ I believe this could be expressed upstream, with `readonly Foo[]`.
.../routers/lib/typescript/src/types.js.flow | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/types/@react-navigation/routers/lib/typescript/src/types.js.flow b/types/@react-navigation/routers/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/routers/lib/typescript/src/types.js.flow types/@react-navigation/routers/lib/typescript/src/types.js.flow
index 574ad164b..65d187165 100644
--- a/types/@react-navigation/routers/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/routers/lib/typescript/src/types.js.flow
--- types/@react-navigation/routers/lib/typescript/src/types.js.flow
+++ types/@react-navigation/routers/lib/typescript/src/types.js.flow
@@ -12,9 +12,9 @@ type NavigationRoute<ParamList: ParamListBase, RouteName: $Keys<ParamList>> = Ro
export type NavigationState<ParamList: ParamListBase = ParamListBase> = Readonly<{
key: string,
Expand All @@ -26,5 +26,5 @@ index 574ad164b..65d187165 100644
stale: false,
...
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Subject: [upstream] rnav: $ReadOnly on ResetState as param of reset()
.../routers/lib/typescript/src/CommonActions.js.flow | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow b/types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
diff --git types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
index 0976fd765..dcd559b0a 100644
--- a/types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
+++ b/types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
--- types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
+++ types/@react-navigation/routers/lib/typescript/src/CommonActions.js.flow
@@ -71,6 +71,6 @@ declare export function navigate(
): Action;

Expand All @@ -20,5 +20,5 @@ index 0976fd765..dcd559b0a 100644
declare export function setParams(params: { ... }): Action;
export {};
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ case. For example, our `typesEquivalent` in src/generics.js.
.../stack/lib/typescript/src/types.js.flow | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/types/@react-navigation/core/lib/typescript/src/types.js.flow b/types/@react-navigation/core/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/core/lib/typescript/src/types.js.flow types/@react-navigation/core/lib/typescript/src/types.js.flow
index b6145283b..e3dd9a0d0 100644
--- a/types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/core/lib/typescript/src/types.js.flow
--- types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ types/@react-navigation/core/lib/typescript/src/types.js.flow
@@ -181,7 +181,7 @@ type NavigationHelpersCommon<

export type NavigationHelpers<
Expand Down Expand Up @@ -59,10 +59,10 @@ index b6145283b..e3dd9a0d0 100644
> = {
render(): $tsflower_subst$React$JSX$Element,
options: ScreenOptions,
diff --git a/types/@react-navigation/stack/lib/typescript/src/types.js.flow b/types/@react-navigation/stack/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/stack/lib/typescript/src/types.js.flow types/@react-navigation/stack/lib/typescript/src/types.js.flow
index 946df1eb6..94ea2dee5 100644
--- a/types/@react-navigation/stack/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/stack/lib/typescript/src/types.js.flow
--- types/@react-navigation/stack/lib/typescript/src/types.js.flow
+++ types/@react-navigation/stack/lib/typescript/src/types.js.flow
@@ -43,7 +43,7 @@ export type StackNavigationHelpers = NavigationHelpers<ParamListBase, StackNavig
StackActionHelpers<ParamListBase>;
export type StackNavigationProp<
Expand All @@ -73,5 +73,5 @@ index 946df1eb6..94ea2dee5 100644
ParamList,
RouteName,
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ not some other.
types/@react-navigation/core/lib/typescript/src/types.js.flow | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/types/@react-navigation/core/lib/typescript/src/types.js.flow b/types/@react-navigation/core/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/core/lib/typescript/src/types.js.flow types/@react-navigation/core/lib/typescript/src/types.js.flow
index e3dd9a0d0..41f13ea18 100644
--- a/types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/core/lib/typescript/src/types.js.flow
--- types/@react-navigation/core/lib/typescript/src/types.js.flow
+++ types/@react-navigation/core/lib/typescript/src/types.js.flow
@@ -202,7 +202,7 @@ export type NavigationContainerProps = {
export type NavigationProp<
ParamList: ParamListBase,
Expand All @@ -23,5 +23,5 @@ index e3dd9a0d0..41f13ea18 100644
EventMap: EventMapBase = EventMapBase,
> = NavigationHelpersCommon<ParamList, State> & {
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Content-Transfer-Encoding: 8bit
.../typescript/src/navigators/createStackNavigator.js.flow | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow b/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
diff --git types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
index 69f6df9c8..29d53b3ff 100644
--- a/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
+++ b/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
--- types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
+++ types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
@@ -21,10 +21,10 @@ type Props = DefaultNavigatorOptions<MaterialTopTabNavigationOptions> &
MaterialTopTabNavigationConfig;
declare function MaterialTopTabNavigator(Props): $tsflower_subst$React$JSX$Element;
Expand All @@ -29,10 +29,10 @@ index 69f6df9c8..29d53b3ff 100644
MaterialTopTabNavigationOptions,
MaterialTopTabNavigationEventMap,
typeof MaterialTopTabNavigator,
diff --git a/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow b/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
diff --git types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
index 7a17b58e6..1842836b1 100644
--- a/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
+++ b/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
--- types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
+++ types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
@@ -21,10 +21,10 @@ type Props = DefaultNavigatorOptions<StackNavigationOptions> &
StackNavigationConfig;
declare function StackNavigator(Props): $tsflower_subst$React$JSX$Element;
Expand All @@ -47,5 +47,5 @@ index 7a17b58e6..1842836b1 100644
StackNavigationEventMap,
typeof StackNavigator,
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Subject: [upstream] rnav: Covariant indexer in ParamListBase
.../@react-navigation/routers/lib/typescript/src/types.js.flow | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/types/@react-navigation/routers/lib/typescript/src/types.js.flow b/types/@react-navigation/routers/lib/typescript/src/types.js.flow
diff --git types/@react-navigation/routers/lib/typescript/src/types.js.flow types/@react-navigation/routers/lib/typescript/src/types.js.flow
index 65d187165..a194fa5fa 100644
--- a/types/@react-navigation/routers/lib/typescript/src/types.js.flow
+++ b/types/@react-navigation/routers/lib/typescript/src/types.js.flow
--- types/@react-navigation/routers/lib/typescript/src/types.js.flow
+++ types/@react-navigation/routers/lib/typescript/src/types.js.flow
@@ -70,7 +70,7 @@ export type Route<RouteName: string, Params: { ... } | void = { ... } | void> =
params: Readonly<Params>;
}> */ /* tsflower-unimplemented: ConditionalType */;
Expand All @@ -21,5 +21,5 @@ index 65d187165..a194fa5fa 100644
export type NavigationAction = Readonly<{
type: string,
--
2.32.0 (Apple Git-132)
2.32.0

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Rather than to the upper bound on ParamList.
.../lib/typescript/src/navigators/createStackNavigator.js.flow | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow b/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
diff --git types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
index 29d53b3ff..def19204a 100644
--- a/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
+++ b/types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
--- types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
+++ types/@react-navigation/material-top-tabs/lib/typescript/src/navigators/createMaterialTopTabNavigator.js.flow
@@ -24,7 +24,7 @@ declare var _default: <
ParamList: { +[key: string]: { ... } | void },
>() => $tsflower_import_type$_$_40_react_2d_navigation_2f_native$TypedNavigator<
Expand All @@ -26,10 +26,10 @@ index 29d53b3ff..def19204a 100644
MaterialTopTabNavigationOptions,
MaterialTopTabNavigationEventMap,
typeof MaterialTopTabNavigator,
diff --git a/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow b/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
diff --git types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
index 1842836b1..3c2939d32 100644
--- a/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
+++ b/types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
--- types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
+++ types/@react-navigation/stack/lib/typescript/src/navigators/createStackNavigator.js.flow
@@ -24,7 +24,7 @@ declare var _default: <
ParamList: { +[key: string]: { ... } | void },
>() => $tsflower_import_type$_$_40_react_2d_navigation_2f_native$TypedNavigator<
Expand All @@ -40,5 +40,5 @@ index 1842836b1..3c2939d32 100644
StackNavigationEventMap,
typeof StackNavigator,
--
2.32.0 (Apple Git-132)
2.32.0

Loading