Skip to content

Commit b1b9871

Browse files
committed
refactor (#364)
1 parent e7e4ba2 commit b1b9871

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

git-ref/src/fullname.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ impl FullName {
109109
/// Strip well-known prefixes from the name and return it.
110110
///
111111
/// If there is no such prefix, the original name is returned.
112-
pub fn strip_prefix(&self) -> &BStr {
113-
self.to_ref().strip_prefix()
112+
pub fn shorten(&self) -> &BStr {
113+
self.to_ref().shorten()
114114
}
115115

116116
/// Classify this name, or return `None` if it's unclassified.

git-ref/src/name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a> FullNameRef<'a> {
3737
/// Strip well-known prefixes from the name and return it.
3838
///
3939
/// If there is no such prefix, the original name is returned.
40-
pub fn strip_prefix(&self) -> &'a BStr {
40+
pub fn shorten(&self) -> &'a BStr {
4141
let n = self.as_bstr();
4242
n.strip_prefix(b"refs/tags/")
4343
.or_else(|| n.strip_prefix(b"refs/heads/"))

git-ref/tests/fullname/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn file_name() {
77
assert_eq!(name.to_ref().file_name(), "main");
88
}
99
#[test]
10-
fn strip_prefix() {
10+
fn shorten_and_category() {
1111
for (input, expected, category) in [
1212
("refs/tags/tag-name", "tag-name", Category::Tag),
1313
("refs/heads/main", "main", Category::LocalBranch),
@@ -16,16 +16,16 @@ fn strip_prefix() {
1616
] {
1717
let name: git_ref::FullName = input.try_into().unwrap();
1818
let category = Some(category);
19-
assert_eq!(name.to_ref().strip_prefix(), expected);
20-
assert_eq!(name.strip_prefix(), expected);
19+
assert_eq!(name.to_ref().shorten(), expected);
20+
assert_eq!(name.shorten(), expected);
2121
assert_eq!(name.category(), category);
2222
assert_eq!(name.to_ref().category(), category);
2323
}
2424

2525
let special = "HEAD";
2626
let name: git_ref::FullName = special.try_into().unwrap();
2727
assert_eq!(
28-
name.strip_prefix(),
28+
name.shorten(),
2929
special,
3030
"the whole name is returned if there is no prefix"
3131
);

git-repository/src/reference/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use crate::ext::ObjectIdExt;
1515

1616
pub mod log;
1717

18+
pub use git_ref::{Category, Kind};
19+
1820
/// Access
1921
impl<'repo> Reference<'repo> {
2022
/// Return the target to which this reference points to.

0 commit comments

Comments
 (0)