Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions gitoxide-core/src/repository/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ enum Error {
Configuration(#[from] gix::config::credential_helpers::Error),
#[error(transparent)]
Protocol(#[from] gix::credentials::protocol::Error),
#[error(transparent)]
ConfigLoad(#[from] gix::config::file::init::from_paths::Error),
}

pub fn function(repo: gix::Repository, action: gix::credentials::program::main::Action) -> anyhow::Result<()> {
pub fn function(repo: Option<gix::Repository>, action: gix::credentials::program::main::Action) -> anyhow::Result<()> {
use gix::credentials::program::main::Action::*;
gix::credentials::program::main(
Some(action.as_str().into()),
Expand All @@ -20,9 +22,24 @@ pub fn function(repo: gix::Repository, action: gix::credentials::program::main::
.clone()
.or_else(|| context.to_url())
.ok_or(Error::Protocol(gix::credentials::protocol::Error::UrlMissing))?;
let (mut cascade, _action, prompt_options) = repo
.config_snapshot()
.credential_helpers(gix::url::parse(url.as_ref())?)?;

let (mut cascade, _action, prompt_options) = match repo {
Some(ref repo) => repo
.config_snapshot()
.credential_helpers(gix::url::parse(url.as_ref())?)?,
None => {
let config = gix::config::File::from_globals()?;
let environment = gix::open::permissions::Environment::all();
gix::config::credential_helpers(
gix::url::parse(url.as_ref())?,
&config,
false, /* lenient config */
|_| true, /* section filter */
environment,
false, /* use http path (override, uses configuration now)*/
)?
}
};
cascade
.invoke(
match action {
Expand Down
2 changes: 1 addition & 1 deletion src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ pub fn main() -> Result<()> {
}
Subcommands::ConfigTree => show_progress(),
Subcommands::Credential(cmd) => core::repository::credential(
repository(Mode::StrictWithGitInstallConfig)?,
repository(Mode::StrictWithGitInstallConfig).ok(),
match cmd {
credential::Subcommands::Fill => gix::credentials::program::main::Action::Get,
credential::Subcommands::Approve => gix::credentials::program::main::Action::Store,
Expand Down
Loading