History

restore full ref names for baseline (#450)

Sebastian Thiel committed 4 years ago

Commit f6124db1 parent 3000a141 file · +17 −3Browse files

Unified · Split

git-refspec/tests/matcher/mod.rs+17−3
@@ -10,7 +10,7 @@ fn fetch_only() { · 9 unmodified lines
1010 }
1111
1212 mod baseline {
13− use bstr::{BString, ByteSlice};
13+ use bstr::{BString, ByteSlice, ByteVec};
1414 use git_hash::ObjectId;
1515 use std::collections::HashMap;
1616
@@ -75,8 +75,8 @@ mod baseline { · 58 unmodified lines
7575 drop(tokens.next());
7676 let rhs = tokens.next().unwrap().trim();
7777 mappings.push(Mapping {
78− remote: lhs.into(),
79− local: rhs.into(),
78+ remote: full_remote_ref(lhs.into()),
79+ local: full_tracking_ref(rhs.into()),
8080 })
8181 }
8282 }
@@ -84,4 +84,18 @@ mod baseline { · 1 unmodified line
8484
8585 Ok(map)
8686 }
87+
88+ fn full_remote_ref(mut name: BString) -> BString {
89+ if !name.contains(&b'/') {
90+ name.insert_str(0, b"refs/heads/");
91+ }
92+ name
93+ }
94+
95+ fn full_tracking_ref(mut name: BString) -> BString {
96+ if name.starts_with_str(b"origin/") {
97+ name.insert_str(0, b"refs/remotes/");
98+ }
99+ name
100+ }
87101 }