use worktrunk::git::Repository;
pub fn wip_message() -> String {
let host = gethostname::gethostname().to_string_lossy().into_owned();
let ts = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
format!("wip @ {host} — {ts}")
}
pub fn resolve_remote(repo: &Repository, branch: &str) -> anyhow::Result<String> {
Ok(repo
.branch(branch)
.push_remote()
.unwrap_or_else(|| "origin".to_string()))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn wip_message_contract() {
let _: fn() -> String = wip_message;
let msg = wip_message();
assert!(msg.starts_with("wip @ "), "got: {msg}");
assert!(msg.contains(" — "), "got: {msg}");
}
}