Skip to content

Commit

Permalink
adapt to changes in git-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 24, 2022
1 parent 84d594c commit 1c2e755
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion cargo-smart-release/src/command/release/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ pub fn push_tags_and_head(
.into_remote(git::remote::Direction::Push)
.ok_or_else(|| anyhow!("Cannot push in uninitialized repo"))??
.name()
.expect("configured remotes have a name"),
.expect("configured remotes have a name")
.as_bstr()
.to_string(),
)
.arg("HEAD");
for tag_name in tag_names {
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/organize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn find_origin_remote(repo: &Path) -> anyhow::Result<Option<git_url::Url>> {
let config = git::config::File::from_path_no_includes(non_bare.as_path(), local)
.or_else(|_| git::config::File::from_path_no_includes(repo.join("config").as_path(), local))?;
Ok(config
.string("remote", Some("origin"), "url")
.string_by_key("remote.origin.url")
.map(|url| git_url::Url::from_bytes(url.as_ref()))
.transpose()?)
}
Expand Down
14 changes: 7 additions & 7 deletions gitoxide-core/src/repository/config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use anyhow::{bail, Result};
use git::bstr::{BStr, BString};
use git_repository as git;
use git_repository::bstr::BString;

use crate::OutputFormat;

pub fn list(
repo: git::Repository,
filters: Vec<String>,
filters: Vec<BString>,
overrides: Vec<BString>,
format: OutputFormat,
mut out: impl std::io::Write,
Expand Down Expand Up @@ -52,18 +52,18 @@ pub fn list(

struct Filter {
name: String,
subsection: Option<String>,
subsection: Option<BString>,
}

impl Filter {
fn new(input: String) -> Self {
match git::config::parse::key(&input) {
fn new(input: BString) -> Self {
match git::config::parse::key(<_ as AsRef<BStr>>::as_ref(&input)) {
Some(key) => Filter {
name: key.section_name.into(),
subsection: key.subsection_name.map(ToOwned::to_owned),
},
None => Filter {
name: input,
name: input.to_string(),
subsection: None,
},
}
Expand All @@ -77,7 +77,7 @@ impl Filter {
}
match (self.subsection.as_deref(), section.header().subsection_name()) {
(Some(filter), Some(name)) => {
if !git::glob::wildmatch(filter.as_bytes().into(), name, ignore_case) {
if !git::glob::wildmatch(filter.as_slice().into(), name, ignore_case) {
return false;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ pub enum Subcommands {
}

pub mod config {
use git::bstr::BString;
use git_repository as git;

/// Print all entries in a configuration file or access other sub-commands
#[derive(Debug, clap::Parser)]
#[clap(subcommand_required(false))]
Expand All @@ -114,7 +117,8 @@ pub mod config {
///
/// Typical filters are `branch` or `remote.origin` or `remote.or*` - git-style globs are supported
/// and comparisons are case-insensitive.
pub filter: Vec<String>,
#[clap(parse(try_from_os_str = git::env::os_str_to_bstring))]
pub filter: Vec<BString>,
}
}

Expand Down

0 comments on commit 1c2e755

Please sign in to comment.