Skip to content

Commit

Permalink
fallback to clone specific commit on demand (#25)
Browse files Browse the repository at this point in the history
* fallback to clone specific commit on demand

* typo

* singe checkout

---------

Co-authored-by: dbaranov34 <[email protected]>
  • Loading branch information
dbaranovstonfi and dbaranov34 authored Jun 27, 2024
1 parent b63c692 commit f775fbb
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() {
build();
}

const TON_MONOREPO_REVISION: &str = "testnet";
const TON_MONOREPO_REVISION: &str = "38fc1d5456cb16864668535ac6c4d6ba8fde9cbc";
const TON_MONOREPO_DIR: &str = "./ton";

#[cfg(not(feature = "shared-tonlib"))]
Expand Down Expand Up @@ -45,24 +45,39 @@ fn build() {
])
.status()
.unwrap();
if clone_status.success() {
let checkout_status = Command::new("git")
.current_dir(TON_MONOREPO_DIR)
.args(["checkout", TON_MONOREPO_DIR])

if !clone_status.success() {
// fallback to clone entire repo and then checkout desired commit
let full_clone_status = Command::new("git")
.args([
"clone",
"--recurse-submodules", // clone submodules as well
"--shallow-submodules", // get only the latest commit of submodules
"https://github.com/ton-blockchain/ton",
TON_MONOREPO_DIR,
])
.status()
.unwrap();

if checkout_status.success() {
println!("Cloned and checked out specific commit successfully!");
if full_clone_status.success() {
println!("Cloned repository successfully!");
} else {
println!("Failed to checkout specific commit!");
panic!("Failed to clone repository!");
}
};

let checkout_status = Command::new("git")
.current_dir(TON_MONOREPO_DIR)
.args(["checkout", TON_MONOREPO_REVISION])
.status()
.unwrap();

if checkout_status.success() {
println!("Cloned and checked out specific commit successfully!");
} else {
println!("Failed to clone repository!");
}
if !clone_status.success() {
panic!("Git clone TON repo fail");
panic!("Failed to checkout specific commit!");
}

let update_submodules_status = Command::new("git")
.current_dir(TON_MONOREPO_DIR)
.args(["submodule", "update", "--init", "--recursive"])
Expand Down

0 comments on commit f775fbb

Please sign in to comment.