Skip to content

Commit d1159da

Browse files
fixup! core: allow to install a branch
1 parent 8ef4d35 commit d1159da

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

coffee_core/src/coffee.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ impl PluginManager for CoffeeManager {
288288
plugin.exec_path = new_exec_path;
289289

290290
if let Some(branch) = branch {
291-
let _ = git_checkout(&plugin.root_path, &branch, verbose).await?;
291+
// FIXME: Where we store the date? how we manage it?
292+
let (commit, _) =
293+
git_checkout(&plugin.root_path, &branch, verbose).await?;
294+
plugin.commit = Some(commit);
292295
}
293296

294297
log::debug!("plugin: {:?}", plugin);

coffee_github/src/utils.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,14 @@ pub async fn git_checkout(
5353
path: &str,
5454
branch: &str,
5555
verbose: bool,
56-
) -> Result<UpgradeStatus, CoffeeError> {
57-
let repo = git2::Repository::open(path).map_err(|err| error!("{}", err.message()))?;
58-
let (local_commit, _) = get_repo_info!(repo);
59-
56+
) -> Result<(String, String), CoffeeError> {
6057
let mut cmd = format!("git fetch origin\n");
6158
cmd += &format!("git reset --hard\n");
6259
cmd += &format!("git checkout origin/{branch}");
6360
sh!(path, cmd, verbose);
6461

62+
let repo = git2::Repository::open(path).map_err(|err| error!("{}", err.message()))?;
6563
let (upstream_commit, date) = get_repo_info!(repo);
6664

67-
if local_commit == upstream_commit {
68-
Ok(UpgradeStatus::UpToDate(upstream_commit, date))
69-
} else {
70-
Ok(UpgradeStatus::Updated(upstream_commit, date))
71-
}
65+
Ok((upstream_commit, date))
7266
}

0 commit comments

Comments
 (0)