add ent sync
In a worktree with the `entomologist-data` branch checked out in it: 1. `git fetch REMOTE` 2. `git merge REMOTE/BRANCH` 3. `git push REMOTE BRANCH` Pretty straight-forward. If anything goes wrong we error out and ask the human to help.
This commit is contained in:
parent
ccabfa4ec8
commit
9c54a92152
2 changed files with 83 additions and 0 deletions
|
|
@ -45,6 +45,15 @@ enum Commands {
|
|||
issue_id: String,
|
||||
description: Option<String>,
|
||||
},
|
||||
|
||||
/// Sync entomologist data with remote. This fetches from the remote,
|
||||
/// merges the remote entomologist data branch with the local one,
|
||||
/// and pushes the result back to the remote.
|
||||
Sync {
|
||||
/// Name of the git remote to sync with.
|
||||
#[arg(default_value_t = String::from("origin"))]
|
||||
remote: String,
|
||||
},
|
||||
}
|
||||
|
||||
fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> {
|
||||
|
|
@ -154,6 +163,24 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Commands::Sync { remote } => {
|
||||
if args.issues_dir.is_some() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"`sync` operates on a branch, don't specify `issues_dir`"
|
||||
));
|
||||
}
|
||||
// FIXME: Kinda bogus to re-do this thing we just did in
|
||||
// `main()`. Maybe `main()` shouldn't create the worktree,
|
||||
// maybe we should do it here in `handle_command()`?
|
||||
// That way also each command could decide if it wants a
|
||||
// read-only worktree or a read/write one.
|
||||
let branch = match &args.issues_branch {
|
||||
Some(branch) => branch,
|
||||
None => "entomologist-data",
|
||||
};
|
||||
entomologist::git::sync(issues_dir, remote, branch)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue