Resolve "fatal: not a git repository" error outside of git repositories

Summary:
CocoaPods will display a "fatal: not a git repository" when these podspecs are consumed within Facebook's internal Mercurial repository due to the reliance on `git` to obtain the current commit hash.

In these cases, the podspec is being consumed locally and the commit hash is unnecessary.

The error is removed by avoiding the use of `git` if the current working directory is not a git repository (or any of the parent directories).

Changelog:
[Internal] [iOS] - Remove CocoaPods error within Facebook's repository

Reviewed By: fkgozali

Differential Revision: D27750974

fbshipit-source-id: 99159611c580baf5526f116948c5ff60e1c02e5c
This commit is contained in:
Héctor Ramos 2021-04-15 13:29:06 -07:00 коммит произвёл Facebook GitHub Bot
Родитель e1eb938c9d
Коммит ae07c53d0b
33 изменённых файлов: 63 добавлений и 63 удалений

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -12,7 +12,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -12,7 +12,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -9,7 +9,7 @@ version = package['version']
source = { :git => ENV['INSTALL_YOGA_FROM_LOCATION'] || 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -839,8 +839,8 @@ SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: 91e874a8823933a268c38765a88cbd5dba1fa024
FBReactNativeSpec: 6793f00102a091fb931674853172fb22e5a2c4cf
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
FBReactNativeSpec: 8f209368616796eed1c127e6933dbfd7a117bc02
Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021
Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41
Flipper-Folly: f7a3caafbd74bda4827954fd7a6e000e36355489
@ -852,34 +852,34 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c
RCTRequired: 047bd218d23dbe95d2a933eb5030a269d2a42929
RCTTypeSafety: c2fc670603ca48eb4c1230091eaffb422e6d0d4d
React: 8acdd3dbc39d3413461725c645553bc76d275630
React-callinvoker: 42d87829505c1bfa2174ddaeb9272a147c81e998
React-Core: 2d53d893ddeff7a58e7ed51b43a15a3d94c3c4a7
React-CoreModules: c096a150e14753b07dc68a498508da4e55b026e9
React-cxxreact: 14cce64344ab482615dfe82a2cbea6eb73be6481
React-Fabric: 641ddc4b27a2611f483430a043557668fec81bf9
React-graphics: 246b8e6cb4aad51271358767c965e47d692921ab
React-jsi: 08c6628096d2025d4085fbaec8fe14a3c9dc667c
React-jsiexecutor: 896c41b04121803e4ee61e4c9ed0900fdb420fea
React-jsinspector: 52fe8073736a97304c9bc61a5bbae8b66ca55701
React-perflogger: e5c447a0435eb9cdd1e5cd692a48b5c5463406b0
React-RCTActionSheet: 555656ac47e1b81d986a3822e22c374523e0ed17
React-RCTAnimation: 0bb7a765e92907fb44073438b3a6752ca4ef0df1
React-RCTBlob: b0af8ae625ea63199504c9cfe09151ebeae51884
React-RCTFabric: 447f94b853788b8868157002022bcaa911f2cf00
React-RCTImage: 8626895dc6dabc11f28e3d6a9eb866b2e2c2742d
React-RCTLinking: 61d39d94ade2207b36a61262cff0d6fe97c89879
React-RCTNetwork: 088b12d5836099ab1e1bd25fc6c8eb07689e7138
React-RCTPushNotification: 6b749f4433b8e69974da2a2ba65bbbd980b8556d
React-RCTSettings: 3ff97019291c40903d88ed062642a4fe07d2971d
React-RCTTest: 19f1b769a4bd35ca36bc48645fb218441fc8277d
React-RCTText: 83931feaad2b470868af24bf7b943cc52a84603d
React-RCTVibration: c739e240076fd7dabd90d6242d6a949297565f72
React-runtimeexecutor: d3e89935c7d4733ddf7da3dd8e0b2533adb7bca4
ReactCommon: 959d51c4ce5f5885ffd44115a38052dc45b4a489
Yoga: 69c2b21737d8220f647e61141aec8c28f7249ef2
RCTRequired: af2d6080a4b9ba0885b28ca78879a92066c71cab
RCTTypeSafety: 1f6703f07db0433102c53a39b08c441bc74f726c
React: f64c9f6db5428717922a3292ba6a448615a2e143
React-callinvoker: c5d61e29df57793f0dc10ec2bc01c846f863e51f
React-Core: 836e8f265a3e09f5fb0825adfb6faadf463de80f
React-CoreModules: 3fc3961a1cf09c44fa89112f38d89d7d17f2226c
React-cxxreact: af0510bcae9cc043745bf4db10bbb1df6e1d4233
React-Fabric: 7e588c340d211a421ff0c0b2dbe9a10459e300d7
React-graphics: 463ffef0254d060a19b0aafbd823375f9ae45ce7
React-jsi: 438d26574ec476e7721eecad31fdcded76d6afcc
React-jsiexecutor: 588df2ae1a96e056bacefc385034376532473a4b
React-jsinspector: 7d223826b0e7a61b3540c21b9eca2603b1d4e823
React-perflogger: fe66bd6d8b17ebcfdf0159bf41fe28d8035ac20c
React-RCTActionSheet: 3131a0b9280aa0e51bdf54b3d79aecd8503db62c
React-RCTAnimation: bcdc239589d8d8f03ccd3ac08ce550c6306ca1fd
React-RCTBlob: c17a7eb29ce26af864230caf8504ca5878a39a83
React-RCTFabric: 5a57c86ed7049e1f0e7bf8119f51119924cd6c85
React-RCTImage: 54722ec7185c9d2b04866a030bdf790c9fcea445
React-RCTLinking: 559c9223212ab2824950883220582c5e29a6fcb2
React-RCTNetwork: 61729312eb9450f73d0962d7784e01860dd081f2
React-RCTPushNotification: fafeb247db030c4d3f0a098d729e49f62ed32b3f
React-RCTSettings: 80f2296a3f5b94801ea45d2d31154289edd11861
React-RCTTest: 0001858946dbe9f6f055efebb90164160b1ab15d
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
React-RCTVibration: aea79a107cfcbfcf9a55ca44b00cb00334d4d4ec
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
ReactCommon: 970d8ca9a8cac68c650c26a38e34d02132c65eea
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
PODFILE CHECKSUM: 6e910a576b7db9347c60dfc58f7852f692200116

Просмотреть файл

@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end

Просмотреть файл

@ -89,9 +89,9 @@ main() {
describe "Copying output to final directory"
mkdir -p "$CODEGEN_COMPONENTS_OUTPUT_DIR" "$CODEGEN_MODULES_OUTPUT_DIR"
cp -R "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME-generated.mm" "$CODEGEN_MODULES_OUTPUT_DIR" || exit 1
cp -v -R "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$CODEGEN_MODULES_LIBRARY_NAME-generated.mm" "$CODEGEN_MODULES_OUTPUT_DIR" || exit 1
find "$TEMP_OUTPUT_DIR" -type f | xargs sed -i.bak "s/$CODEGEN_MODULES_LIBRARY_NAME/$CODEGEN_COMPONENTS_LIBRARY_NAME/g" || exit 1
find "$TEMP_OUTPUT_DIR" -type f -not -iname "$CODEGEN_MODULES_LIBRARY_NAME*" -exec cp '{}' "$CODEGEN_COMPONENTS_OUTPUT_DIR/" ';' || exit 1
find "$TEMP_OUTPUT_DIR" -type f -not -iname "$CODEGEN_MODULES_LIBRARY_NAME*" -exec cp -v '{}' "$CODEGEN_COMPONENTS_OUTPUT_DIR/" ';' || exit 1
echo >&2 'Done.'
}