Skip to content

Commit

Permalink
temp: refactor ReferenceName 2
Browse files Browse the repository at this point in the history
  • Loading branch information
arxanas committed Aug 27, 2022
1 parent 0bfd81b commit f3c67f9
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 325 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions git-branchless-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ tracing-chrome = "0.6.0"
tracing-error = "0.2.0"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
once_cell = "1.13.0"
thiserror = "1.0.32"

[dev-dependencies]
criterion = { version = "0.3.6", features = ["html_reports"] }
Expand Down
18 changes: 9 additions & 9 deletions git-branchless-lib/src/core/check_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use eyre::Context;
use tracing::instrument;

use crate::git::{
update_index, CategorizedReferenceName, GitRunInfo, MaybeZeroOid, Repo, Stage,
update_index, CategorizedReferenceName, GitRunInfo, MaybeZeroOid, ReferenceName, Repo, Stage,
UpdateIndexCommand, WorkingCopySnapshot,
};
use crate::util::ExitCode;
Expand Down Expand Up @@ -48,7 +48,7 @@ pub fn check_out_commit(
repo: &Repo,
event_log_db: &EventLogDb,
event_tx_id: EventTransactionId,
target: Option<impl AsRef<OsStr> + std::fmt::Debug>,
target: Option<&str>,
options: &CheckOutCommitOptions,
) -> eyre::Result<ExitCode> {
let CheckOutCommitOptions {
Expand All @@ -59,7 +59,8 @@ pub fn check_out_commit(
let target = match target {
None => None,
Some(target) => {
let categorized_target = CategorizedReferenceName::new(target.as_ref());
let reference_name = ReferenceName::from(target);
let categorized_target = CategorizedReferenceName::new(&reference_name);
Some(categorized_target.remove_prefix()?)
}
};
Expand All @@ -71,7 +72,7 @@ pub fn check_out_commit(
let args = {
let mut args = vec![OsStr::new("checkout")];
if let Some(target) = &target {
args.push(target);
args.push(OsStr::new(target.as_str()));
}
args.extend(additional_args.iter().map(OsStr::new));
args
Expand All @@ -86,8 +87,7 @@ pub fn check_out_commit(
effects.get_glyphs(),
StyledString::styled(
match target {
Some(target) =>
format!("Failed to check out commit: {}", target.to_string_lossy()),
Some(target) => format!("Failed to check out commit: {target}"),
None => "Failed to check out commit".to_string(),
},
BaseColor::Red.light()
Expand Down Expand Up @@ -148,7 +148,7 @@ pub fn create_snapshot<'repo>(
event_tx_id,
head_oid: MaybeZeroOid::from(head_info.oid),
commit_oid: snapshot.base_commit.get_oid(),
ref_name: head_info.reference_name.map(|name| name.into_owned()),
ref_name: head_info.reference_name,
}])?;
Ok(snapshot)
}
Expand Down Expand Up @@ -274,7 +274,7 @@ pub fn restore_snapshot(
.run(
effects,
Some(event_tx_id),
&["update-ref", ref_name, &head_oid.to_string()],
&["update-ref", ref_name.as_str(), &head_oid.to_string()],
)
.context("Restoring snapshot branch")?;
if !exit_code.is_success() {
Expand All @@ -285,7 +285,7 @@ pub fn restore_snapshot(
.run(
effects,
Some(event_tx_id),
&["symbolic-ref", "HEAD", ref_name],
&["symbolic-ref", "HEAD", ref_name.as_str()],
)
.context("Checking out snapshot branch")?;
if !exit_code.is_success() {
Expand Down
Loading

0 comments on commit f3c67f9

Please sign in to comment.