Enum git_refspec::match_group::SourceRef
source · Expand description
The source (or left-hand) side of a mapping, which references its name.
Variants§
FullName(&'a BStr)
A full reference name, which is expected to be valid.
Validity, however, is not enforced here.
ObjectId(ObjectId)
The name of an object that is expected to exist on the remote side. Note that it might not be advertised by the remote but part of the object graph, and thus gets sent in the pack. The server is expected to fail unless the desired object is present but at some time it is merely a request by the user.
Implementations§
source§impl SourceRef<'_>
impl SourceRef<'_>
sourcepub fn to_owned(&self) -> Source
pub fn to_owned(&self) -> Source
Create a fully owned instance from this one.
Examples found in repository?
src/match_group/validate.rs (line 114)
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
pub fn validated(mut self) -> Result<(Self, Vec<Fix>), Error> {
let mut sources_by_destinations = BTreeMap::new();
for (dst, (spec_index, src)) in self
.mappings
.iter()
.filter_map(|m| m.rhs.as_ref().map(|dst| (dst.as_ref(), (m.spec_index, &m.lhs))))
{
let sources = sources_by_destinations.entry(dst).or_insert_with(Vec::new);
if !sources.iter().any(|(_, lhs)| lhs == &src) {
sources.push((spec_index, src))
}
}
let mut issues = Vec::new();
for (dst, conflicting_sources) in sources_by_destinations.into_iter().filter(|(_, v)| v.len() > 1) {
issues.push(Issue::Conflict {
destination_full_ref_name: dst.to_owned(),
specs: conflicting_sources
.iter()
.map(|(spec_idx, _)| self.group.specs[*spec_idx].to_bstring())
.collect(),
sources: conflicting_sources.into_iter().map(|(_, src)| src.to_owned()).collect(),
})
}
if !issues.is_empty() {
Err(Error { issues })
} else {
let mut fixed = Vec::new();
let group = &self.group;
self.mappings.retain(|m| match m.rhs.as_ref() {
Some(dst) => {
if dst.starts_with(b"refs/") || dst.as_ref() == "HEAD" {
true
} else {
fixed.push(Fix::MappingWithPartialDestinationRemoved {
name: dst.as_ref().to_owned(),
spec: group.specs[m.spec_index].to_owned(),
});
false
}
}
None => true,
});
Ok((self, fixed))
}
}
Trait Implementations§
source§impl<'a> PartialEq<SourceRef<'a>> for SourceRef<'a>
impl<'a> PartialEq<SourceRef<'a>> for SourceRef<'a>
impl<'a> Copy for SourceRef<'a>
impl<'a> Eq for SourceRef<'a>
impl<'a> StructuralEq for SourceRef<'a>
impl<'a> StructuralPartialEq for SourceRef<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for SourceRef<'a>
impl<'a> Send for SourceRef<'a>
impl<'a> Sync for SourceRef<'a>
impl<'a> Unpin for SourceRef<'a>
impl<'a> UnwindSafe for SourceRef<'a>
Blanket Implementations§
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more