Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move data type and retrieval crates into hc_data #39

Merged
merged 18 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 10 additions & 69 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion libs/hc_analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false

[dependencies]
hc_common = { path = "../hc_common" }
hc_git = { path = "../hc_git" }
hc_data = { path = "../hc_data" }
hc_metric = { path = "../hc_metric" }
hc_config = { path = "../hc_config" }
hc_report = { path = "../hc_report" }
2 changes: 1 addition & 1 deletion libs/hc_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hc_common::{
salsa, F64,
};
use hc_config::{AttacksConfigQuery, CommitConfigQuery, FuzzConfigQuery, PracticesConfigQuery};
use hc_git::GitProvider;
use hc_data::git::GitProvider;
use hc_metric::{affiliation::AffiliatedType, MetricProvider};
use hc_report::{Concern, PrConcern};
use std::collections::{HashMap, HashSet};
Expand Down
18 changes: 12 additions & 6 deletions libs/hc_data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ license = "Apache-2.0"
publish = false

[dependencies]
dirs = "5.0.1"
graphql_client = "0.14.0"
hc_common = { path = "../hc_common" }
hc_config = { path = "../hc_config" }
hc_eslint = { path = "../hc_eslint" }
hc_git = { path = "../hc_git" }
hc_github = { path = "../hc_github" }
hc_npm = { path = "../hc_npm" }
hc_source = { path = "../hc_source" }
hc_git_command = { path = "../hc_git_command" }
hc_hash = { path = "../hc_hash" }
hc_shell = { path = "../hc_shell" }
hc_version = { path = "../hc_version" }
hc_modules = { path = "../hc_modules" }
nom = "7.1.3"
petgraph = { version = "0.6.0", features = ["serde-1"] }
serde = { path = "../hc_serde", package = "hc_serde" }
ureq = { version = "2.9.7", default-features = false, features = ["json", "native-tls"] }

[dev-dependencies]
dirs = "5.0.1"
tempfile = "3.2.0"
4 changes: 2 additions & 2 deletions libs/hc_data/src/code_quality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use std::path::{Path, PathBuf};

use crate::es_lint::data::{ESLintMessage, ESLintReports};
use crate::es_lint::get_eslint_reports;
use hc_common::{error::Result, hc_error};
use hc_eslint::data::{ESLintMessage, ESLintReports};
use hc_eslint::get_eslint_reports;

pub type CodeQualityReport = Vec<FileFindings>;

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions libs/hc_eslint/src/lib.rs → libs/hc_data/src/es_lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ use hc_common::{error::Result, semver::Version, serde_json};
pub mod command;
pub mod data;

#[allow(unused)]
pub fn get_eslint_version() -> Result<String> {
ESLintCommand::internal([OsStr::new("--version")])?.output()
}

#[allow(unused)]
pub fn parse_eslint_version(version: &str) -> Result<Version> {
// semver's parser will not accept the leading 'v' or trailing newline
let version = version.strip_prefix('v').unwrap_or(version);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/hc_git/src/lib.rs → libs/hc_data/src/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mod query;

pub use data::*;
pub use hc_git_command::*;
use parse::*;
pub use query::*;

use crate::parse::*;
use hc_common::context::Context as _;
use hc_common::{
error::{Error, Result},
Expand Down
2 changes: 1 addition & 1 deletion libs/hc_git/src/parse.rs → libs/hc_data/src/git/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![allow(dead_code)]

use crate::{Contributor, Diff, FileDiff, RawCommit};
use crate::git::{Contributor, Diff, FileDiff, RawCommit};
use hc_common::context::Context as _;
use hc_common::{
chrono::{DateTime, FixedOffset},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Derived query implementations for the `GitProvider` query group.

use super::GitProvider;
use crate::{
use crate::git::{
get_commits, get_commits_from_date, get_diffs, Commit, CommitContributor,
CommitContributorView, CommitDiff, CommitSigner, CommitSignerView, Contributor,
ContributorView, Diff, GitCommand, RawCommit, SignerKeyView, SignerNameView, SignerView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
mod impls;

use crate::{
Commit, CommitContributor, CommitContributorView, CommitDiff, CommitSigner, CommitSignerView,
Contributor, ContributorView, Diff, RawCommit, SignerKeyView, SignerNameView, SignerView,
git::{
Commit, CommitContributor, CommitContributorView, CommitDiff, CommitSigner,
CommitSignerView, Contributor, ContributorView, Diff, RawCommit, SignerKeyView,
SignerNameView, SignerView,
},
source::SourceQuery,
};
use hc_common::{chrono::prelude::*, error::Result, salsa};
use hc_source::SourceQuery;
use hc_version::VersionQuery;
use std::rc::Rc;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Defines an authenticated [`Agent`] type that adds token auth to all requests.

use crate::hidden::Hidden;
use crate::github::hidden::Hidden;
use ureq::{Agent, Request};

/// An [`Agent`] which authenticates requests with token auth.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

use crate::authenticated_agent::AuthenticatedAgent;
use crate::github::authenticated_agent::AuthenticatedAgent;
use hc_common::{
error::{Error, Result},
hc_error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

use hc_git::{Diff, RawCommit};
use crate::git::{Diff, RawCommit};

use serde::Deserialize;
#[derive(Debug, Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::convert::TryInto;

use self::reviews::{ResponseData, ReviewsRepositoryPullRequestsNodes as RawPull, Variables};
use crate::{authenticated_agent::AuthenticatedAgent, data::*};
use crate::github::{authenticated_agent::AuthenticatedAgent, data::*};
use graphql_client::{GraphQLQuery, QueryBody, Response};
use hc_common::{
error::{Error, Result},
Expand All @@ -17,8 +17,8 @@ const GH_API_V4: &str = "https://api.github.com/graphql";
/// Defines the query being made against the GitHub API.
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/gh_schema.graphql",
query_path = "src/gh_query.graphql",
schema_path = "src/github/gh_schema.graphql",
query_path = "src/github/gh_query.graphql",
response_derives = "Debug"
)]
pub struct Reviews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use self::review::{
ResponseData, ReviewRepositoryPullRequest as RawPull,
ReviewRepositoryPullRequestCommitsNodes as RawPullCommit, Variables,
};
use crate::{authenticated_agent::AuthenticatedAgent, data::*};
use crate::{
git::{Contributor, RawCommit},
github::{authenticated_agent::AuthenticatedAgent, data::*},
};
use graphql_client::{GraphQLQuery, QueryBody, Response};
use hc_common::{
chrono::DateTime,
Expand All @@ -13,7 +16,6 @@ use hc_common::{
hc_error,
serde_json::{from_value as from_json_value, to_value as to_json_value},
};
use hc_git::{Contributor, RawCommit};
use std::convert::TryFrom;

/// The URL of the GitHub GraphQL API.
Expand All @@ -22,8 +24,8 @@ const GH_API_V4: &str = "https://api.github.com/graphql";
/// Defines the query being made against the GitHub API.
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/gh_schema.graphql",
query_path = "src/gh_query.graphql",
schema_path = "src/github/gh_schema.graphql",
query_path = "src/github/gh_query.graphql",
response_derives = "Debug"
)]
pub struct Review;
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions libs/hc_github/src/lib.rs → libs/hc_data/src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ mod graphql;
mod graphql_pr;
mod hidden;

use crate::authenticated_agent::AuthenticatedAgent;
use crate::code_search::search_code_request;
use crate::data::*;
use crate::graphql::get_all_reviews;
use crate::graphql_pr::get_all_pr_reviews;
use crate::git::parse::github_diff;
use crate::github::authenticated_agent::AuthenticatedAgent;
use crate::github::data::*;
use crate::github::graphql::get_all_reviews;
use crate::github::graphql_pr::get_all_pr_reviews;
use hc_common::context::Context as _;
use hc_common::{error::Result, log};
use hc_git::parse::github_diff;
use std::rc::Rc;

pub struct GitHub<'a> {
Expand Down
15 changes: 9 additions & 6 deletions libs/hc_data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
//! Functions and types for data retrieval.

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

pub use hc_git as git;
pub use hc_modules as modules;
pub use hc_npm as npm;
pub use query::*;
use std::collections::HashSet;

use git::{get_commits_for_file, Commit, CommitContributor, Contributor, Diff};
use github::*;
use hc_common::{
context::Context,
error::Error,
error::Result,
hc_error, log, pathbuf,
serde::{self, Serialize},
};
use hc_git::{get_commits_for_file, Commit, CommitContributor, Contributor, Diff};
use hc_github::*;
use hc_modules::RawModule;
use modules::RawModule;
use petgraph::visit::Dfs;
use petgraph::Graph;
use std::path::Path;
Expand Down
Loading