Skip to content

Commit

Permalink
feat: add remote::Names as shortcut to the value returned for all r…
Browse files Browse the repository at this point in the history
…emote names.
  • Loading branch information
Byron committed Aug 7, 2024
1 parent 2e00b5e commit 7c8f409
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions gix/src/remote/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;

use crate::bstr::BStr;
use std::borrow::Cow;
use std::collections::BTreeSet;

/// The direction of an operation carried out (or to be carried out) through a remote.
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
Expand Down Expand Up @@ -31,6 +31,9 @@ pub enum Name<'repo> {
Url(Cow<'repo, BStr>),
}

/// A type-definition for a sorted list of unvalidated remote names - they have been read straight from the configuration.
pub type Names<'a> = BTreeSet<Cow<'a, BStr>>;

///
#[allow(clippy::empty_docs)]
pub mod name;
Expand Down
4 changes: 2 additions & 2 deletions gix/src/repository/config/remote.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::bstr::BStr;
use std::{borrow::Cow, collections::BTreeSet};
use std::borrow::Cow;

use crate::config::tree::{Remote, Section};
use crate::remote;
Expand All @@ -8,7 +8,7 @@ use crate::remote;
impl crate::Repository {
/// Returns a sorted list unique of symbolic names of remotes that
/// we deem [trustworthy][crate::open::Options::filter_config_section()].
pub fn remote_names(&self) -> BTreeSet<Cow<'_, BStr>> {
pub fn remote_names(&self) -> remote::Names<'_> {
self.config
.resolved
.sections_by_name(Remote.name())
Expand Down

0 comments on commit 7c8f409

Please sign in to comment.