Skip to content

Commit

Permalink
feat: Removed pathbuf module in favor of crate.
Browse files Browse the repository at this point in the history
A while back I'd made a published crate called `pathbuf` that does the
same stuff we'd been doing in our own `pathbuf.rs` file, so let's just
use that instead of having our own code for it.

Signed-off-by: Andrew Lilley Brinker <[email protected]>
  • Loading branch information
alilleybrinker committed May 7, 2024
1 parent 2d199d6 commit 6a82fdf
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 104 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion hipcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ lazy_static = "1.4.0"
log = "0.4.16"
libc = "0.2.154"
maplit = "1.0.2"
native-tls = "0.2.11"
nom = "7.1.3"
once_cell = "1.10.0"
ordered-float = { version = "4.2.0", features = ["serde"] }
paste = "1.0.7"
pathbuf = "1.0.0"
petgraph = { version = "0.6.0", features = ["serde-1"] }
regex = "1.5.5"
salsa = "0.16.1"
Expand All @@ -59,7 +61,6 @@ url = "2.2.2"
walkdir = "2.5.0"
which = { version = "6.0.1", default-features = false }
xml-rs = "0.8.20"
native-tls = "0.2.11"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.9"
Expand Down
8 changes: 4 additions & 4 deletions hipcheck/src/analysis/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use crate::error::Error;
use crate::error::Result;
use crate::filesystem::create_dir_all;
use crate::hc_error;
use crate::pathbuf;
use crate::report::Format;
use crate::report::ReportParams;
use crate::report::ReportParamsStorage;
Expand All @@ -51,6 +50,7 @@ use crate::version::VersionQueryStorage;
use crate::HIPCHECK_TOML_FILE;
use chrono::prelude::*;
use dotenv::var;
use pathbuf::pathbuf;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::fmt;
Expand Down Expand Up @@ -372,7 +372,7 @@ pub fn resolve_config(config_flag: Option<&Path>) -> Result<PathBuf> {
// (See https://docs.rs/dirs/3.0.2/dirs/fn.cache_dir.html)

if let Some(config_path) = config_flag {
let full_config_path = pathbuf![&config_path, HIPCHECK_TOML_FILE];
let full_config_path = pathbuf![config_path, HIPCHECK_TOML_FILE];
if full_config_path.exists() {
return Ok(full_config_path);
}
Expand Down Expand Up @@ -673,7 +673,7 @@ mod tests {
],
|| {
let data_dir = None;
let data_path = pathbuf![dirs::data_dir().unwrap(), "hipcheck"];
let data_path = pathbuf![&dirs::data_dir().unwrap(), "hipcheck"];
create_dir_all(data_path.as_path()).unwrap();
let result = resolve_data(data_dir).unwrap();
let path = result.to_str().unwrap();
Expand Down Expand Up @@ -748,7 +748,7 @@ mod tests {
("HC_DATA", None),
],
|| {
let data_path = pathbuf![dirs::data_dir().unwrap(), "hipcheck"];
let data_path = pathbuf![&dirs::data_dir().unwrap(), "hipcheck"];
create_dir_all(data_path.as_path()).unwrap();
let result = resolve_data(None).unwrap();
let path = result.to_str().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use crate::context::Context;
use crate::error::Result;
use crate::filesystem as file;
use crate::pathbuf;
use crate::BINARY_CONFIG_FILE;
use crate::F64;
use crate::LANGS_FILE;
use crate::ORGS_FILE;
use crate::TYPO_FILE;
use pathbuf::pathbuf;
use serde::Deserialize;
use serde::Serialize;
use smart_default::SmartDefault;
Expand Down
13 changes: 7 additions & 6 deletions hipcheck/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@

//! Functions and types for data retrieval.
mod code_quality;
mod es_lint;
pub mod git;
pub mod git_command;
pub mod npm;
pub mod source;

mod code_quality;
mod es_lint;
mod github;
mod hash;
mod modules;
pub mod npm;
mod query;
pub mod source;

pub use query::*;
use std::collections::HashSet;

use crate::context::Context;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use git::get_commits_for_file;
use git::Commit;
use git::CommitContributor;
use git::Contributor;
use git::Diff;
use github::*;
use modules::RawModule;
use pathbuf::pathbuf;
use petgraph::visit::Dfs;
use petgraph::Graph;
use serde::Serialize;
use std::collections::HashSet;
use std::path::Path;
use std::rc::Rc;

Expand Down
4 changes: 2 additions & 2 deletions hipcheck/src/data/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::context::Context as _;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use pathbuf::pathbuf;
use serde::Deserialize;
use serde_json::Value as JsonValue;
use std::collections::HashMap;
Expand All @@ -21,7 +21,7 @@ use std::process::Command;

pub fn generate_module_model(repo_dir: &Path, module_deps: &Path) -> Result<Vec<RawModule>> {
let root = detect_npm_package_root(&pathbuf![repo_dir, "package.json"])?;
if !pathbuf![&repo_dir, &root].exists() {
if !pathbuf![repo_dir, &root].exists() {
return Err(Error::msg(
"Unable to identify module structure of repository code",
));
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::context::Context;
use crate::error::Result;
use crate::filesystem as file;
use crate::hc_error;
use crate::pathbuf;
use pathbuf::pathbuf;
use serde::Deserialize;
use std::collections::HashMap;
use std::convert::AsRef;
Expand Down
8 changes: 3 additions & 5 deletions hipcheck/src/data/query/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

//! Query group for module information.
use std::path::PathBuf;
use std::rc::Rc;

use crate::data::associate_modules_and_commits;
use crate::data::git::Commit;
use crate::data::git::GitProvider;
use crate::data::Module;
use crate::data::ModuleGraph;

use crate::error::Error;
use crate::error::Result;
use crate::pathbuf;
use pathbuf::pathbuf;
use std::path::PathBuf;
use std::rc::Rc;

/// A module and an associated commit
pub type ModuleCommitMap = Rc<Vec<(Rc<Module>, Rc<Commit>)>>;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::data::git_command::GitCommand;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use crate::shell::Phase;
use log::debug;
use pathbuf::pathbuf;
use std::ffi::OsStr;
use std::fmt;
use std::fmt::Debug;
Expand Down
8 changes: 4 additions & 4 deletions hipcheck/src/data/source/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::data::source::Remote;
use crate::data::source::Source;
use crate::hash;
use crate::pathbuf;
use pathbuf::pathbuf;
use std::path::PathBuf;
use std::rc::Rc;

Expand Down Expand Up @@ -80,14 +80,14 @@ fn storage_path(db: &dyn SourceQuery) -> Rc<PathBuf> {
repo,
pull_request,
..
} => pathbuf!["remote", "github", owner, repo, pull_request.to_string()],
} => pathbuf!["remote", "github", owner, repo, &pull_request.to_string()],
// This is an unknown remote source.
Unknown(url) => pathbuf!["remote", "unknown", hash!(url).to_string()],
Unknown(url) => pathbuf!["remote", "unknown", &hash!(url).to_string()],
},
// This is a local source.
None => match db.local().file_name() {
Some(file_name) => pathbuf!["local", file_name],
None => pathbuf!["local", "unknown", hash!(db.local()).to_string()],
None => pathbuf!["local", "unknown", &hash!(db.local()).to_string()],
},
};

Expand Down
1 change: 0 additions & 1 deletion hipcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod context;
mod data;
mod error;
mod filesystem;
mod pathbuf;
mod report;
mod shell;
#[cfg(test)]
Expand Down
78 changes: 0 additions & 78 deletions hipcheck/src/pathbuf.rs

This file was deleted.

0 comments on commit 6a82fdf

Please sign in to comment.