A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GitoxideLabs/gitoxide/commit/d7db360d5b42ec9d2b4d9977f7b7bee0f6cc4d58 below:

committer_or_set_generic_fallback()`. · GitoxideLabs/gitoxide@d7db360 · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+28

-30

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+28

-30

lines changed Original file line number Diff line number Diff line change

@@ -1,7 +1,6 @@

1 1

use crate::{

2 2

bstr::{BString, ByteSlice},

3 3

clone::PrepareFetch,

4 -

config::tree::gitoxide,

5 4

};

6 5 7 6

/// The error returned by [`PrepareFetch::fetch_only()`].

@@ -46,6 +45,8 @@ pub enum Error {

46 45

wanted: gix_ref::PartialName,

47 46

candidates: Vec<BString>,

48 47

},

48 +

#[error(transparent)]

49 +

CommitterOrFallback(#[from] crate::config::time::Error),

49 50

}

50 51 51 52

/// Modification

@@ -81,23 +82,11 @@ impl PrepareFetch {

81 82

.as_mut()

82 83

.expect("user error: multiple calls are allowed only until it succeeds");

83 84 84 -

if repo.committer().is_none() {

85 -

let mut config = gix_config::File::new(gix_config::file::Metadata::api());

86 -

config

87 -

.set_raw_value(&gitoxide::Committer::NAME_FALLBACK, "no name configured during fetch")

88 -

.expect("works - statically known");

89 -

config

90 -

.set_raw_value(&gitoxide::Committer::EMAIL_FALLBACK, "noEmailAvailable@example.com")

91 -

.expect("works - statically known");

92 -

let mut repo_config = repo.config_snapshot_mut();

93 -

repo_config.append(config);

94 -

repo_config.commit().expect("configuration is still valid");

95 -

}

85 +

repo.committer_or_set_generic_fallback()?;

96 86 97 87

if !self.config_overrides.is_empty() {

98 88

let mut snapshot = repo.config_snapshot_mut();

99 89

snapshot.append_config(&self.config_overrides, gix_config::Source::Api)?;

100 -

snapshot.commit()?;

101 90

}

102 91 103 92

let remote_name = match self.remote_name.as_ref() {

Original file line number Diff line number Diff line change

@@ -1,5 +1,5 @@

1 1

#![allow(clippy::result_large_err)]

2 -

use crate::{bstr::BString, config::tree::gitoxide, remote};

2 +

use crate::{bstr::BString, remote};

3 3 4 4

type ConfigureRemoteFn =

5 5

Box<dyn FnMut(crate::Remote<'_>) -> Result<crate::Remote<'_>, Box<dyn std::error::Error + Send + Sync>>>;

@@ -46,6 +46,8 @@ pub enum Error {

46 46

#[error(transparent)]

47 47

Init(#[from] crate::init::Error),

48 48

#[error(transparent)]

49 +

CommitterOrFallback(#[from] crate::config::time::Error),

50 +

#[error(transparent)]

49 51

UrlParse(#[from] gix_url::parse::Error),

50 52

#[error("Failed to turn a the relative file url \"{}\" into an absolute one", url.to_bstring())]

51 53

CanonicalizeUrl {

@@ -102,18 +104,7 @@ impl PrepareFetch {

102 104

url: url.clone(),

103 105

source: err,

104 106

})?;

105 -

if repo.committer().is_none() {

106 -

let mut config = gix_config::File::new(gix_config::file::Metadata::api());

107 -

config

108 -

.set_raw_value(&gitoxide::Committer::NAME_FALLBACK, "no name configured during clone")

109 -

.expect("works - statically known");

110 -

config

111 -

.set_raw_value(&gitoxide::Committer::EMAIL_FALLBACK, "noEmailAvailable@example.com")

112 -

.expect("works - statically known");

113 -

let mut repo_config = repo.config_snapshot_mut();

114 -

repo_config.append(config);

115 -

repo_config.commit().expect("configuration is still valid");

116 -

}

107 +

repo.committer_or_set_generic_fallback()?;

117 108

Ok(PrepareFetch {

118 109

url,

119 110

#[cfg(any(feature = "async-network-client", feature = "blocking-network-client"))]

Original file line number Diff line number Diff line change

@@ -43,6 +43,24 @@ impl crate::Repository {

43 43

.into()

44 44

}

45 45 46 +

/// Return the committer or its fallback just like [`committer()`](Self::committer()), but if *not* set generate a

47 +

/// possibly arbitrary fallback and configure it in memory on this instance. That fallback is then returned and future

48 +

/// calls to [`committer()`](Self::committer()) will return it as well.

49 +

pub fn committer_or_set_generic_fallback(&mut self) -> Result<gix_actor::SignatureRef<'_>, config::time::Error> {

50 +

if self.committer().is_none() {

51 +

let mut config = gix_config::File::new(gix_config::file::Metadata::api());

52 +

config

53 +

.set_raw_value(&gitoxide::Committer::NAME_FALLBACK, "no name configured")

54 +

.expect("works - statically known");

55 +

config

56 +

.set_raw_value(&gitoxide::Committer::EMAIL_FALLBACK, "noEmailAvailable@example.com")

57 +

.expect("works - statically known");

58 +

let mut repo_config = self.config_snapshot_mut();

59 +

repo_config.append(config);

60 +

}

61 +

self.committer().expect("committer was just set")

62 +

}

63 + 46 64

/// Return the author as configured by this repository, which is determined by…

47 65

///

48 66

/// * …the git configuration `author.name|email`…

Original file line number Diff line number Diff line change

@@ -268,7 +268,7 @@ mod with_overrides {

268 268

Ok(())

269 269

}

270 270 271 -

fn cow_bstr(s: &str) -> Cow<BStr> {

271 +

fn cow_bstr(s: &str) -> Cow<'_, BStr> {

272 272

Cow::Borrowed(s.into())

273 273

}

274 274

}

Original file line number Diff line number Diff line change

@@ -334,7 +334,7 @@ mod blocking_io {

334 334

.expect("one line")?

335 335

.signature

336 336

.to_owned()?;

337 -

assert_eq!(sig.name, "no name configured during clone");

337 +

assert_eq!(sig.name, "no name configured");

338 338

assert_eq!(sig.email, "noEmailAvailable@example.com");

339 339 340 340

match out.status {

Original file line number Diff line number Diff line change

@@ -879,7 +879,7 @@ mod track_rewrites {

879 879

}

880 880

}

881 881 882 -

fn tree_named(repo: &gix::Repository, rev_spec: impl AsRef<str>) -> gix::Tree {

882 +

fn tree_named(repo: &gix::Repository, rev_spec: impl AsRef<str>) -> gix::Tree<'_> {

883 883

repo.rev_parse_single(rev_spec.as_ref())

884 884

.unwrap()

885 885

.object()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4