style(fedora): Implicit types and module consts
Use type inferencing for variables and move default repo filter to a constant. Signed-off-by: innocentzero <isfarulhaque@proton.me>
This commit is contained in:
@@ -18,17 +18,21 @@ const BINARY: Text = "dnf";
|
|||||||
const SECTION: Text = "fedora";
|
const SECTION: Text = "fedora";
|
||||||
|
|
||||||
const SWITCHES_INFO: Switches = &[
|
const SWITCHES_INFO: Switches = &[
|
||||||
"repoquery",
|
const SWITCHES_INFO: Switches = &["info"];
|
||||||
"--installed",
|
|
||||||
"--queryformat",
|
|
||||||
"%{from_repo}/%{name}",
|
|
||||||
];
|
|
||||||
const SWITCHES_INSTALL: Switches = &["install"];
|
const SWITCHES_INSTALL: Switches = &["install"];
|
||||||
const SWITCHES_MAKE_DEPENDENCY: Switches = &[];
|
const SWITCHES_MAKE_DEPENDENCY: Switches = &[];
|
||||||
const SWITCHES_NOCONFIRM: Switches = &["--assumeyes"];
|
const SWITCHES_NOCONFIRM: Switches = &["--assumeyes"];
|
||||||
const SWITCHES_REMOVE: Switches = &["remove"];
|
const SWITCHES_REMOVE: Switches = &["remove"];
|
||||||
|
|
||||||
|
"repoquery",
|
||||||
|
"--installed",
|
||||||
|
"--queryformat",
|
||||||
|
"%{from_repo}/%{name}",
|
||||||
|
];
|
||||||
|
|
||||||
const SUPPORTS_AS_DEPENDENCY: bool = true;
|
const SUPPORTS_AS_DEPENDENCY: bool = true;
|
||||||
|
/// fill stuff here
|
||||||
|
const DEFAULT_REPOS: [&str; 5] = ["koji", "fedora", "updates", "anaconda", "@"];
|
||||||
|
|
||||||
impl Backend for Fedora {
|
impl Backend for Fedora {
|
||||||
impl_backend_constants!();
|
impl_backend_constants!();
|
||||||
@@ -38,7 +42,7 @@ impl Backend for Fedora {
|
|||||||
cmd.args(self.get_switches_info());
|
cmd.args(self.get_switches_info());
|
||||||
|
|
||||||
let output = String::from_utf8(cmd.output()?.stdout)?;
|
let output = String::from_utf8(cmd.output()?.stdout)?;
|
||||||
let packages: HashSet<Package> = output.lines().map(create_package).collect();
|
let packages = output.lines().map(create_package).collect();
|
||||||
|
|
||||||
Ok(packages)
|
Ok(packages)
|
||||||
}
|
}
|
||||||
@@ -53,7 +57,7 @@ impl Backend for Fedora {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
let output = String::from_utf8(cmd.output()?.stdout)?;
|
let output = String::from_utf8(cmd.output()?.stdout)?;
|
||||||
let packages: HashSet<Package> = output.lines().map(create_package).collect();
|
let packages = output.lines().map(create_package).collect();
|
||||||
|
|
||||||
Ok(packages)
|
Ok(packages)
|
||||||
}
|
}
|
||||||
@@ -112,13 +116,7 @@ impl Fedora {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_package(package: &str) -> Package {
|
fn create_package(package: &str) -> Package {
|
||||||
if (package.contains("koji")
|
if DEFAULT_REPOS.iter().any(|repo| package.contains(repo)) && !package.contains("copr") {
|
||||||
|| package.contains("fedora")
|
|
||||||
|| package.contains("updates")
|
|
||||||
|| package.contains("anaconda")
|
|
||||||
|| package.contains('@'))
|
|
||||||
&& !package.contains("copr")
|
|
||||||
{
|
|
||||||
let package = package.split('/').nth(1).expect("Cannot be empty!");
|
let package = package.split('/').nth(1).expect("Cannot be empty!");
|
||||||
package.into()
|
package.into()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user