mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-01 17:50:03 +00:00
Rm unnecessary warning msg "Failed to read git credential file" (#1479)
* Rm unnecessary warning msg "Failed to read git credential file" Fixed #1476 If `gh auth token` executed successfully and binstall obtained a gh token from it, then there's no reason to issue any warning msg. Only when binstall cannot read from `.git-credential` and `gh auth token` failed does binstall need to issue warning. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix clippy warning Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
3414c4ee83
commit
d76a40bf7d
3 changed files with 11 additions and 29 deletions
|
@ -2,7 +2,6 @@ use std::{env, fs, path::PathBuf};
|
|||
|
||||
use compact_str::CompactString;
|
||||
use dirs::home_dir;
|
||||
use tracing::warn;
|
||||
|
||||
pub fn try_from_home() -> Option<CompactString> {
|
||||
if let Some(mut home) = home_dir() {
|
||||
|
@ -25,7 +24,8 @@ pub fn try_from_home() -> Option<CompactString> {
|
|||
}
|
||||
|
||||
fn from_file(path: PathBuf) -> Option<CompactString> {
|
||||
read_cred_file(path)?
|
||||
fs::read_to_string(path)
|
||||
.ok()?
|
||||
.lines()
|
||||
.find_map(from_line)
|
||||
.map(CompactString::from)
|
||||
|
@ -40,20 +40,6 @@ fn from_line(line: &str) -> Option<&str> {
|
|||
Some(cred.split_once(':')?.1)
|
||||
}
|
||||
|
||||
fn read_cred_file(path: PathBuf) -> Option<String> {
|
||||
match fs::read_to_string(&path) {
|
||||
Ok(s) => Some(s),
|
||||
Err(err) => {
|
||||
warn!(
|
||||
?err,
|
||||
"Failed to read git credential file {}",
|
||||
path.display()
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue