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
10}10}
11 11
12mod baseline {12mod baseline {
13 use bstr::{BString, ByteSlice};13 use bstr::{BString, ByteSlice, ByteVec};
14 use git_hash::ObjectId;14 use git_hash::ObjectId;
15 use std::collections::HashMap;15 use std::collections::HashMap;
16 16
@@ -75,8 +75,8 @@ mod baseline { · 58 unmodified lines
75 drop(tokens.next());75 drop(tokens.next());
76 let rhs = tokens.next().unwrap().trim();76 let rhs = tokens.next().unwrap().trim();
77 mappings.push(Mapping {77 mappings.push(Mapping {
78 remote: lhs.into(),78 remote: full_remote_ref(lhs.into()),
79 local: rhs.into(),79 local: full_tracking_ref(rhs.into()),
80 })80 })
81 }81 }
82 }82 }
@@ -84,4 +84,18 @@ mod baseline { · 1 unmodified line
84 84
85 Ok(map)85 Ok(map)
86 }86 }
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 }
87}101}