Skip to content

Commit

Permalink
[ref #152] no silent failure if path conversion isn't possible
Browse files Browse the repository at this point in the history
For now we are loud about it for the lack of a better way to do certain
transformations on windows.

The API remains the same though, assuming that eventually we will
do some rewriting and possibly return a PathBuf instead, hence 'Cow'.
  • Loading branch information
Byron committed Aug 9, 2021
1 parent 67d5c85 commit 8df04d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-ref/src/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl FullName {

/// Convert this name into the relative path, lossily, identifying the reference location relative to a repository
pub fn to_path(&self) -> Cow<'_, Path> {
self.0.to_path_lossy()
self.0.to_path().expect("UTF-8 conversion always succeeds").into()
}

/// Dissolve this instance and return the buffer.
Expand Down
4 changes: 2 additions & 2 deletions git-ref/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub type Error = git_validate::reference::name::Error;
impl<'a> FullName<'a> {
/// Convert this name into the relative path identifying the reference location.
pub fn to_path(self) -> Cow<'a, Path> {
self.0.to_path_lossy()
self.0.to_path().expect("UTF-8 conversion always succeeds").into()
}

/// Return ourselves as byte string which is a valid refname
Expand All @@ -21,7 +21,7 @@ impl<'a> PartialName<'a> {
/// Convert this name into the relative path possibly identifying the reference location.
/// Note that it may be only a partial path though.
pub fn to_partial_path(self) -> Cow<'a, Path> {
self.0.to_path_lossy()
self.0.to_path().expect("UTF-8 conversion always succeeds").into()
}

/// Provide the name as binary string which is known to be a valid partial ref name.
Expand Down

0 comments on commit 8df04d8

Please sign in to comment.