From b7870e6cda1d8c32ce353381757b4709b6434477 Mon Sep 17 00:00:00 2001 From: Thiago Vinhas Date: Wed, 13 May 2026 14:34:06 -0500 Subject: [PATCH] fix(hermes): pick static_h vs main branch by RCT_HERMES_V1_ENABLED in hermes-utils.rb --- .../sdks/hermes-engine/hermes-utils.rb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/react-native/sdks/hermes-engine/hermes-utils.rb b/packages/react-native/sdks/hermes-engine/hermes-utils.rb index 2118dddea813..8ede597ea56d 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-utils.rb +++ b/packages/react-native/sdks/hermes-engine/hermes-utils.rb @@ -251,14 +251,22 @@ def hermes_commit_at_merge_base() commit = nil Dir.mktmpdir do |tmpdir| hermes_git_dir = File.join(tmpdir, "hermes.git") - # Explicitly use Hermes 'main' branch since the default branch changed to 'static_h' (Hermes V1) - `git clone -q --bare --filter=blob:none --single-branch --branch main #{HERMES_GITHUB_URL} "#{hermes_git_dir}"` - - # If all goes well, this will be the commit hash of Hermes at the time of the merge base on branch 'main' - commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" refs/heads/main`.strip + # Pick the Hermes branch that matches the engine variant we resolve at: + # V1 (Hermes 0.83+ split package) lives on `static_h` + # V0 (legacy) lives on `main` + # Without this gate, RCT_HERMES_V1_ENABLED=1 + from-source fallback + # (no Maven artifact, RCT_BUILD_HERMES_FROM_SOURCE=true) would clone + # V0 source while the rest of the podspec expects hermesvm.framework + # (V1) artifacts. Mirror of the same fix on the JS side in PR #2952. + hermes_branch = hermes_v1_enabled() ? "static_h" : "main" + `git clone -q --bare --filter=blob:none --single-branch --branch #{hermes_branch} #{HERMES_GITHUB_URL} "#{hermes_git_dir}"` + + # Resolve the Hermes commit at the time of the merge base on the + # chosen branch. + commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" refs/heads/#{hermes_branch}`.strip if commit.empty? abort <<-EOS - [Hermes] Unable to find the Hermes commit hash at time #{timestamp} on branch 'main'. + [Hermes] Unable to find the Hermes commit hash at time #{timestamp} on branch '#{hermes_branch}'. EOS end end