Skip to content

Commit

Permalink
Respect no_warn in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Apr 19, 2023
1 parent d4e8935 commit 257e011
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/devel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ pub async fn gendb(config: &mut Config) -> Result<()> {
bold.paint(tr!("Querying AUR..."))
);
}
let warnings = cache_info_with_warnings(&config.raur, &mut config.cache, &aur, ignore).await?;
let warnings = cache_info_with_warnings(
&config.raur,
&mut config.cache,
&aur,
ignore,
&config.no_warn,
)
.await?;
warnings.all(config.color, config.cols);

let bases = Bases::from_iter(warnings.pkgs);
Expand Down
38 changes: 31 additions & 7 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use ansi_term::Style;
use anyhow::{bail, ensure, Context, Result};
use aur_depends::AurBase;
use aur_fetch::Repo;
use globset::GlobSet;
use indicatif::{ProgressBar, ProgressStyle};
use kuchiki::traits::*;
use raur::{ArcPackage as Package, Raur};
Expand Down Expand Up @@ -135,6 +136,7 @@ pub async fn cache_info_with_warnings<'a, S: AsRef<str> + Send + Sync>(
cache: &'a mut raur::Cache,
pkgs: &'a [S],
ignore: &[String],
no_warn: &GlobSet,
) -> StdResult<Warnings<'a>, raur::Error> {
let mut missing = Vec::new();
let mut ood = Vec::new();
Expand All @@ -144,13 +146,16 @@ pub async fn cache_info_with_warnings<'a, S: AsRef<str> + Send + Sync>(
aur_pkgs.retain(|pkg1| pkgs.iter().any(|pkg2| pkg1.name == pkg2.as_ref()));

for pkg in pkgs {
if !ignore.iter().any(|p| p == pkg.as_ref()) && !cache.contains(pkg.as_ref()) {
if !no_warn.is_match(pkg.as_ref())
&& !ignore.iter().any(|p| p == pkg.as_ref())
&& !cache.contains(pkg.as_ref())
{
missing.push(pkg.as_ref())
}
}

for pkg in &aur_pkgs {
if !ignore.iter().any(|p| p.as_str() == pkg.name) {
if no_warn.is_match(&pkg.name) && !ignore.iter().any(|p| p.as_str() == pkg.name) {
if pkg.out_of_date.is_some() {
ood.push(cache.get(pkg.name.as_str()).unwrap().name.as_str());
}
Expand Down Expand Up @@ -194,8 +199,14 @@ pub async fn getpkgbuilds(config: &mut Config) -> Result<i32> {
action.paint("::"),
bold.paint(tr!("Querying AUR..."))
);
let warnings =
cache_info_with_warnings(&config.raur, &mut config.cache, &aur, &config.ignore).await?;
let warnings = cache_info_with_warnings(
&config.raur,
&mut config.cache,
&aur,
&config.ignore,
&GlobSet::empty(),
)
.await?;
ret |= !warnings.missing.is_empty() as i32;
warnings.missing(config.color, config.cols);
let aur = warnings.pkgs;
Expand Down Expand Up @@ -447,8 +458,14 @@ pub async fn new_aur_pkgbuilds(
pub async fn show_comments(config: &mut Config) -> Result<i32> {
let client = config.raur.client();

let warnings =
cache_info_with_warnings(&config.raur, &mut config.cache, &config.targets, &[]).await?;
let warnings = cache_info_with_warnings(
&config.raur,
&mut config.cache,
&config.targets,
&[],
&GlobSet::empty(),
)
.await?;
warnings.missing(config.color, config.cols);
let ret = !warnings.missing.is_empty() as i32;
let bases = Bases::from_iter(warnings.pkgs);
Expand Down Expand Up @@ -616,7 +633,14 @@ pub async fn show_pkgbuilds(config: &mut Config) -> Result<i32> {
let client = config.raur.client();
let aur = aur.iter().map(|t| t.pkg).collect::<Vec<_>>();

let warnings = cache_info_with_warnings(&config.raur, &mut config.cache, &aur, &[]).await?;
let warnings = cache_info_with_warnings(
&config.raur,
&mut config.cache,
&aur,
&[],
&GlobSet::empty(),
)
.await?;
warnings.missing(config.color, config.cols);
let ret = !warnings.missing.is_empty() as i32;
let bases = Bases::from_iter(warnings.pkgs);
Expand Down
4 changes: 3 additions & 1 deletion src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use alpm_utils::Targ;
use ansi_term::Style;
use anyhow::Error;
use aur_depends::Repo;
use globset::GlobSet;
use raur::ArcPackage as Package;
use srcinfo::{ArchVec, Srcinfo};
use term_size::dimensions_stdout;
Expand Down Expand Up @@ -57,7 +58,8 @@ pub async fn info(conf: &mut Config, verbose: bool) -> Result<i32, Error> {
let color = conf.color;
let aur = aur.iter().map(|t| t.pkg).collect::<Vec<_>>();
let warnings =
cache_info_with_warnings(&conf.raur, &mut conf.cache, &aur, &conf.ignore).await?;
cache_info_with_warnings(&conf.raur, &mut conf.cache, &aur, &[], &GlobSet::empty())
.await?;
for pkg in &warnings.missing {
eprintln!(
"{} {}",
Expand Down
11 changes: 9 additions & 2 deletions src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::printtr;
use crate::util::repo_aur_pkgs;

use alpm::PackageReason;
use globset::GlobSet;

use std::cmp::Reverse;
use std::collections::BinaryHeap;
Expand Down Expand Up @@ -73,8 +74,14 @@ pub async fn stats(config: &Config) -> Result<i32> {
.map(|s| s.to_owned())
.collect::<Vec<_>>();

let warnings =
cache_info_with_warnings(&config.raur, &mut cache, &aur_packages, &config.ignore).await?;
let warnings = cache_info_with_warnings(
&config.raur,
&mut cache,
&aur_packages,
&config.ignore,
&GlobSet::empty(),
)
.await?;

version();
print_line_separator(config);
Expand Down

0 comments on commit 257e011

Please sign in to comment.