Skip to content

Commit

Permalink
Add --skipreview #193
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Feb 5, 2021
1 parent 9830c74 commit a6c8511
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 13 deletions.
3 changes: 2 additions & 1 deletion completions/bash
Expand Up @@ -75,7 +75,8 @@ _paru() {
rebuildtree redownload noredownload redownloadall pgpfetch nopgpfetch useask
nouseask combinedupgrade nocombinedupgrade batchinstall nobatchinstall provides
noprovides devel nodevel develsuffixes sudoloop nosudoloop bottomup topdown
newsonupgrade bat batflags chroot nochroot localrepo' 'b d h q r v a')
newsonupgrade bat batflags chroot nochroot localrepo review skipreview'
'b d h q r v a')

show=('news' 'w')
getpkgbuild=('print comments' 'p c')
Expand Down
2 changes: 2 additions & 0 deletions completions/fish
Expand Up @@ -232,3 +232,5 @@ complete -c $progname -n "not $noopt" -l nosudoloop -d 'Do not loop sudo calls i
complete -c $progname -n "not $noopt" -l chroot -d 'Build packages in a chroot' -f
complete -c $progname -n "not $noopt" -l nochroot -d "Don't build packages in a chroot" -f
complete -c $progname -n "not $noopt" -l localrepo -d 'Build packages in a local repo' -f
complete -c $progname -n "not $noopt" -l skipreview -d 'Skip the review process' -f
complete -c $progname -n "not $noopt" -l review -d "Don't kip the review process" -f
3 changes: 3 additions & 0 deletions completions/zsh
Expand Up @@ -101,6 +101,9 @@ _pacman_opts_common=(
'--chroot[Build packages in a chroot]'
"--nochroot[Don't build packages in a chroot]"
'--localrepo[Build packages in a local repo]'

'--upgrademenu[Skip the review process]'
"--upgrademenu[Don't skip the review process]"
)

# options for passing to _arguments: options for --upgrade commands
Expand Down
2 changes: 2 additions & 0 deletions help
Expand Up @@ -49,6 +49,8 @@ New options:
--sortby <field> Sort AUR results by a specific field during search
--searchby <field> Search for packages using a specified field

--skipreview Skip the review process
--noskipreview Don't skip the review process
--[no]upgrademenu Show interactive menu to skip upgrades
--[no]removemake Remove makedepends after install
--[no]cleanafter Remove package sources after successful install
Expand Down
10 changes: 9 additions & 1 deletion man/paru.8
Expand Up @@ -260,7 +260,15 @@ Sort AUR results by a specific field during search. Defaults to votes.
Search for AUR packages by querying the specified field. Defaults to name-desc.

.TP
.B \-\-[no]upgrademenu
.B \-\-skipreview
Skip the review process.

.TP
.B \-\-review
Don't skip the review process.

.TP
.B \-\-upgrademenu
Show a detailed list of updates in a similar format to pacman's VerbosePkgLists
option. (See
.BR pacman.conf(5)).
Expand Down
4 changes: 4 additions & 0 deletions man/paru.conf.5
Expand Up @@ -201,6 +201,10 @@ in other enabled repos.
Build packages in a chroot. This rquires the LocalRepo option to be enabled.
Optionaly a directory may be passed to specify where the create the chroot.

.TP
.B SkipReview
Skip the review process.

.SH BIN
Options belonging to the [bin] section.

Expand Down
2 changes: 2 additions & 0 deletions src/command_line.rs
Expand Up @@ -232,6 +232,8 @@ impl Config {
self.aur_filter = true;
}
Arg::Long("repo") => self.mode = "repo".to_string(),
Arg::Long("skipreview") => self.skip_review = true,
Arg::Long("review") => self.skip_review = false,
Arg::Long("gendb") => self.gendb = true,
Arg::Long("nocheck") => self.no_check = true,
Arg::Long("devel") => self.devel = true,
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Expand Up @@ -196,6 +196,7 @@ pub struct Config {
pub help: bool,
pub version: bool,

pub skip_review: bool,
pub no_check: bool,
pub no_confirm: bool,
pub devel: bool,
Expand Down Expand Up @@ -640,6 +641,7 @@ impl Config {
let mut ok2 = true;

match key {
"SkipReview" => self.skip_review = true,
"BottomUp" => self.sort_mode = "bottomup".into(),
"AurOnly" => self.mode = "aur".into(),
"RepoOnly" => self.mode = "repo".into(),
Expand Down
37 changes: 26 additions & 11 deletions src/install.rs
Expand Up @@ -16,12 +16,12 @@ use crate::{args, exec, news};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet};
use std::env::var;
use std::ffi::OsStr;
use std::fs::{read_dir, read_link, OpenOptions};
use std::io::{stdin, stdout, BufRead, Read, Write};
use std::iter::FromIterator;
use std::path::Path;
use std::process::{Command, Stdio};
use std::ffi::OsStr;

use alpm::Alpm;
use alpm_utils::{DbListExt, Targ};
Expand Down Expand Up @@ -196,16 +196,24 @@ pub async fn install(config: &mut Config, targets_str: &[String]) -> Result<i32>
false
};

if !ask(config, "Proceed to review?", true) {
return Ok(1);
if !config.skip_review {
if !ask(config, "Proceed to review?", true) {
return Ok(1);
}
} else {
if !ask(config, "Proceed with install?", true) {
return Ok(1);
}
}

let bases = Bases::from_iter(actions.iter_build_pkgs().map(|p| p.pkg.clone()));
let srcinfos = download_pkgbuilds(config, &bases).await?;

let ret = review(config, &actions, &srcinfos, &bases)?;
if ret != 0 {
return Ok(ret);
if !config.skip_review {
let ret = review(config, &actions, &srcinfos, &bases)?;
if ret != 0 {
return Ok(ret);
}
}

let mut err = if !config.chroot {
Expand Down Expand Up @@ -379,16 +387,19 @@ fn review<'a>(
{
let file = file?;

if file.file_type()?.is_dir() && file.path().file_name() == Some(OsStr::new(".git")) {
if file.file_type()?.is_dir()
&& file.path().file_name() == Some(OsStr::new(".git"))
{
continue;
}
if file.file_type()?.is_dir() && file.path().file_name() == Some(OsStr::new(".SRCINFO")) {
if file.file_type()?.is_dir()
&& file.path().file_name() == Some(OsStr::new(".SRCINFO"))
{
continue;
}
if file.file_type()?.is_dir() {
let s = format!("{} is a directory\n\n", file.path().display());
let _ =
write!(stdin, "{}", c.bold.paint(s));
let _ = write!(stdin, "{}", c.bold.paint(s));
continue;
}
if file.file_type()?.is_symlink() {
Expand All @@ -401,7 +412,11 @@ fn review<'a>(
continue;
}

let _ = write!(stdin, "{}\n", c.bold.paint(file.path().display().to_string()));
let _ = write!(
stdin,
"{}\n",
c.bold.paint(file.path().display().to_string())
);
if bat {
let output = Command::new(&config.bat_bin)
.arg("-pp")
Expand Down

0 comments on commit a6c8511

Please sign in to comment.