Reload extension file snapshots without Git
This commit is contained in:
+3
-39
@@ -44,7 +44,7 @@ fn copy_tree(source: &Path, destination: &Path) -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
impl World {
|
||||
/// Initialize a fresh world and commit its plain bundled source on main.
|
||||
/// Initialize a fresh world with plain bundled source files, without a Git repository.
|
||||
pub async fn init(dir: &Path, bundle: &Path) -> anyhow::Result<Self> {
|
||||
Self::init_with_progress(dir, bundle, |_| {}).await
|
||||
}
|
||||
@@ -60,44 +60,8 @@ impl World {
|
||||
"Create world folder failed: World already exists: {}",
|
||||
dir.display()
|
||||
);
|
||||
let world = Self::open_with_progress(dir, Some(bundle), &mut progress)
|
||||
.context("Create world folder and seed files failed")?;
|
||||
progress("Create the first commit in /src/sausage");
|
||||
let exec = crate::process::exec(Self {
|
||||
root: world.root.clone(),
|
||||
host_dir: world.host_dir.clone(),
|
||||
processes: world.processes.clone(),
|
||||
})
|
||||
.context("Create source repository failed")?;
|
||||
for args in [
|
||||
vec!["init", "-b", "main"],
|
||||
vec!["add", "."],
|
||||
vec!["commit", "--no-gpg-sign", "-m", "Initial world source"],
|
||||
] {
|
||||
let argv = [
|
||||
vec!["/bin/git.wasm".to_owned()],
|
||||
args.into_iter().map(str::to_owned).collect(),
|
||||
]
|
||||
.concat();
|
||||
let mut output = Vec::new();
|
||||
let code = exec
|
||||
.exec(
|
||||
crate::exec::Command::Argv(argv),
|
||||
crate::exec::Options {
|
||||
cwd: "/src/sausage".into(),
|
||||
..Default::default()
|
||||
},
|
||||
&mut |_, bytes| output.extend_from_slice(bytes),
|
||||
)
|
||||
.await
|
||||
.context("Create source repository failed")?;
|
||||
anyhow::ensure!(
|
||||
code == 0,
|
||||
"Cannot initialize source repository: {}",
|
||||
String::from_utf8_lossy(&output)
|
||||
);
|
||||
}
|
||||
Ok(world)
|
||||
Self::open_with_progress(dir, Some(bundle), &mut progress)
|
||||
.context("Create world folder and seed files failed")
|
||||
}
|
||||
|
||||
/// Open (and create if missing) the world directory `dir`, including `/proc` and `/run` mounts.
|
||||
|
||||
Reference in New Issue
Block a user