Skip to content
Open
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
20 changes: 14 additions & 6 deletions packages/react-native/sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down