Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea's own git commits work on a clean Mac: apps/workspace git_cmd sets EMAIL ([email protected]) when it's unset

shinyobjectz9f8a94cdfd7f
diff --git a/apps/workspace/src/controllers.rs b/apps/workspace/src/controllers.rs
index c2e0fb1f..33074001 100644
--- a/apps/workspace/src/controllers.rs
+++ b/apps/workspace/src/controllers.rs
@@ -65,7 +65,7 @@ fn commit(ws: &Path, paths: &[&Path], what: &str, by: &str) -> R<()> {
let mut add = Command::new("git");
add.arg("-C").arg(ws).args(["add", "-A", "--"]).args(paths);
add.status().map_err(|e| format!("git: {e}"))?;
- let ok = Command::new("git").arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(|e| format!("git: {e}"))?;
+ let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(|e| format!("git: {e}"))?;
if ok.success() { Ok(()) } else { Err(format!("couldn't commit {what}")) }
}
diff --git a/apps/workspace/src/workspace.rs b/apps/workspace/src/workspace.rs
index 377d9e2f..c7bf6cd2 100644
--- a/apps/workspace/src/workspace.rs
+++ b/apps/workspace/src/workspace.rs
@@ -7,8 +7,20 @@ use std::process::Command;
const USAGE: &str = "usage: raea workspace [--json] | raea workspace init [NAME] [--layout monorepo|submodules] | raea workspace adopt DIR [--name NAME] [--layout monorepo|submodules]\n raea project [--json] | raea project new NAME [--storage inline|submodule] | raea project split NAME [--remote URL] | raea project join NAME";
+/// git for raea's own commits. A new Mac has no user.email and a hostname git can't make one from, so every commit
+/// failed with "Author identity unknown" and the person's first project was never made. git reads $EMAIL only when
+/// user.email isn't set, so this gives a fresh Mac an address without overriding anyone's own.
+pub(crate) fn git_cmd() -> Command {
+ let mut c = Command::new("git");
+ if std::env::var_os("EMAIL").is_none() {
+ let user = std::env::var("USER").unwrap_or_else(|_| "raea".into());
+ c.env("EMAIL", format!("{user}@raea.local"));
+ }
+ c
+}
+
pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
- let out = Command::new("git").arg("-C").arg(dir).args(args).output().map_err(|e| format!("git: {e}"))?;
+ let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(|e| format!("git: {e}"))?;
if !out.status.success() {
return Err(format!("git {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
}