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

Lazily query for git branch & remote #33936

Merged
merged 1 commit into from
May 31, 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
25 changes: 15 additions & 10 deletions scripts/hermes/hermes-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,21 @@ function copyPodSpec() {
}

function isOnAReleaseBranch() {
let currentBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();
let currentRemote = execSync('git config --get remote.origin.url')
.toString()
.trim();
return (
currentBranch.endsWith('-stable') &&
currentRemote.endsWith('facebook/react-native.git')
);
try {
let currentBranch = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim();
let currentRemote = execSync('git config --get remote.origin.url')
.toString()
.trim();
return (
currentBranch.endsWith('-stable') &&
currentRemote.endsWith('facebook/react-native.git')
);
} catch (error) {
// If not inside a git repo, we're going to fail here and return.
return false;
}
}

function isOnAReleaseTag() {
Expand Down
9 changes: 6 additions & 3 deletions sdks/hermes-engine/hermes-engine.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# LICENSE file in the root directory of this source tree.

require "json"
require "open3"

# sdks/hermesc/osx-bin/ImportHermesc.cmake
import_hermesc_file=File.join(__dir__, "..", "hermesc", "osx-bin", "ImportHermesc.cmake")
Expand All @@ -13,8 +14,10 @@ package_file = File.join(__dir__, "..", "..", "package.json")
package = JSON.parse(File.read(package_file))
version = package['version']

currentbranch = `git rev-parse --abbrev-ref HEAD`.strip
currentremote = `git config --get remote.origin.url`.strip
# We need to check the current git branch/remote to verify if
# we're on a React Native release branch to actually build Hermes.
currentbranch, err = Open3.capture3("git rev-parse --abbrev-ref HEAD")
currentremote, err = Open3.capture3("git config --get remote.origin.url")

source = {}
git = "https://github.com/facebook/hermes.git"
Expand All @@ -23,7 +26,7 @@ if version == '1000.0.0'
Pod::UI.puts '[Hermes] Hermes needs to be compiled, installing hermes-engine may take a while...'.yellow if Object.const_defined?("Pod::UI")
source[:git] = git
source[:commit] = `git ls-remote https://github.com/facebook/hermes main | cut -f 1`.strip
elsif currentremote.end_with?("facebook/react-native.git") and currentbranch.end_with?("-stable")
elsif currentremote.strip.end_with?("facebook/react-native.git") and currentbranch.strip.end_with?("-stable")
Pod::UI.puts '[Hermes] Detected that you are on a React Native release branch, building Hermes from source...'.yellow if Object.const_defined?("Pod::UI")
source[:git] = git
source[:commit] = `git ls-remote https://github.com/facebook/hermes main | cut -f 1`.strip
Expand Down