Skip to content

Commit

Permalink
tools/tsflower: Set diff.noprefix, to clean up patch format slightly
Browse files Browse the repository at this point in the history
Since I'm looking at these diff config options, take the opportunity
to make this small cleanup.
  • Loading branch information
gnprice authored and chrisbobbe committed Jun 10, 2022
1 parent 9c0bc60 commit 5373ba4
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 132 deletions.
14 changes: 8 additions & 6 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 @@ -193,9 +193,11 @@ write_patches()
rm -f "${patch_dir}"/*.patch

local format_patch_config=(
# Prefix the paths with a/ and b/ (expected by `git am`).
# This is the default, but explicitly override user config.
-c diff.noprefix=false
# 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
Expand Down Expand Up @@ -311,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 Down
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 Down
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 Down
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 Down
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 Down
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 Down
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 Down
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 Down
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ so it has a chance of being right.
.../typescript/src/navigators/createStackNavigator.js.flow | 6 +++---
2 files changed, 4 insertions(+), 6 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 def19204a..2e5c9ffa6 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
@@ -16,9 +16,7 @@ import {
type MaterialTopTabNavigationEventMap,
} from '../types';
Expand All @@ -35,10 +35,10 @@ index def19204a..2e5c9ffa6 100644
declare function MaterialTopTabNavigator(Props): $tsflower_subst$React$JSX$Element;
declare var _default: <
ParamList: { +[key: string]: { ... } | void },
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 3c2939d32..f96ddf688 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
@@ -16,9 +16,9 @@ import {
type StackNavigationEventMap,
} from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ that I hoped it might resolve.)
.../@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 a194fa5fa..ea0e29c32 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
@@ -7,7 +7,7 @@ export type CommonNavigationAction = CommonActions.Action;
type NavigationRoute<ParamList: ParamListBase, RouteName: $Keys<ParamList>> = Route<
Extract<RouteName, string>,
Expand Down
Loading

0 comments on commit 5373ba4

Please sign in to comment.