Skip to content

Commit 403cf82

Browse files
resolve conflicts
2 parents a1e1a9c + 3698af5 commit 403cf82

File tree

39 files changed

+1737
-321
lines changed

39 files changed

+1737
-321
lines changed

.github/workflows/pull_request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ jobs:
157157
# running containers via `services` only works on linux
158158
# https://github.com/actions/runner/issues/1866
159159
- name: Setup postgres
160+
id: postgres
160161
uses: ikalnytskyi/action-setup-postgres@v7
162+
- name: Print Roles
163+
run: psql ${{ steps.postgres.outputs.connection-uri }} -c "select rolname from pg_roles;"
161164
- name: Run tests
162165
run: cargo test --workspace
163166

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enumflags2 = "0.7.11"
2828
ignore = "0.4.23"
2929
indexmap = { version = "2.6.0", features = ["serde"] }
3030
insta = "1.31.0"
31+
oxc_resolver = "1.12.0"
3132
pg_query = "6.1.0"
3233
proc-macro2 = "1.0.66"
3334
quote = "1.0.33"
@@ -38,6 +39,7 @@ schemars = { version = "0.8.22", features = ["indexmap2", "small
3839
serde = "1.0.195"
3940
serde_json = "1.0.114"
4041
similar = "2.6.0"
42+
slotmap = "1.0.7"
4143
smallvec = { version = "1.13.2", features = ["union", "const_new", "serde"] }
4244
strum = { version = "0.27.1", features = ["derive"] }
4345
# this will use tokio if available, otherwise async-std

crates/pgt_cli/src/commands/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use bpaf::Bpaf;
99
use pgt_configuration::{PartialConfiguration, partial_configuration};
1010
use pgt_console::Console;
1111
use pgt_fs::FileSystem;
12+
use pgt_workspace::PartialConfigurationExt;
1213
use pgt_workspace::configuration::{LoadedConfiguration, load_configuration};
13-
use pgt_workspace::settings::PartialConfigurationExt;
14-
use pgt_workspace::workspace::UpdateSettingsParams;
14+
use pgt_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams};
1515
use pgt_workspace::{DynRef, Workspace, WorkspaceError};
1616
use std::ffi::OsString;
1717
use std::path::PathBuf;
@@ -301,6 +301,10 @@ pub(crate) trait CommandRunner: Sized {
301301
let (vcs_base_path, gitignore_matches) =
302302
configuration.retrieve_gitignore_matches(fs, vcs_base_path.as_deref())?;
303303
let paths = self.get_files_to_process(fs, &configuration)?;
304+
workspace.register_project_folder(RegisterProjectFolderParams {
305+
path: fs.working_directory(),
306+
set_as_current_workspace: true,
307+
})?;
304308

305309
workspace.update_settings(UpdateSettingsParams {
306310
workspace_directory: fs.working_directory(),

crates/pgt_cli/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ mod test {
455455
fn termination_diagnostic_size() {
456456
assert_eq!(
457457
std::mem::size_of::<CliDiagnostic>(),
458-
80,
458+
96,
459459
"you successfully decreased the size of the diagnostic!"
460460
)
461461
}

crates/pgt_completions/src/relevance/scoring.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ impl CompletionScore<'_> {
208208
}
209209
}
210210

211+
fn get_schema_name(&self) -> &str {
212+
match self.data {
213+
CompletionRelevanceData::Table(t) => t.name.as_str(),
214+
CompletionRelevanceData::Function(f) => f.name.as_str(),
215+
CompletionRelevanceData::Column(c) => c.name.as_str(),
216+
CompletionRelevanceData::Schema(s) => s.name.as_str(),
217+
CompletionRelevanceData::Policy(p) => p.name.as_str(),
218+
CompletionRelevanceData::Role(r) => r.name.as_str(),
219+
}
220+
}
221+
211222
fn get_schema_name(&self) -> Option<&str> {
212223
match self.data {
213224
CompletionRelevanceData::Function(f) => Some(f.schema.as_str()),

crates/pgt_configuration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ biome_deserialize = { workspace = true, features = ["schema"] }
1616
biome_deserialize_macros = { workspace = true }
1717
bpaf = { workspace = true }
1818
indexmap = { workspace = true }
19+
oxc_resolver = { workspace = true }
1920
pgt_analyse = { workspace = true }
2021
pgt_analyser = { workspace = true }
2122
pgt_console = { workspace = true }

crates/pgt_configuration/src/diagnostics.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use pgt_console::fmt::Display;
22
use pgt_console::{MarkupBuf, markup};
3+
use pgt_diagnostics::adapters::ResolveError;
4+
35
use pgt_diagnostics::{Advices, Diagnostic, Error, LogCategory, MessageAndDescription, Visit};
46
use serde::{Deserialize, Serialize};
57
use std::fmt::{Debug, Formatter};
@@ -21,6 +23,12 @@ pub enum ConfigurationDiagnostic {
2123

2224
/// Thrown when the pattern inside the `ignore` field errors
2325
InvalidIgnorePattern(InvalidIgnorePattern),
26+
27+
/// Thrown when there's something wrong with the files specified inside `"extends"`
28+
CantLoadExtendFile(CantLoadExtendFile),
29+
30+
/// Thrown when a configuration file can't be resolved from `node_modules`
31+
CantResolve(CantResolve),
2432
}
2533

2634
impl ConfigurationDiagnostic {
@@ -72,6 +80,18 @@ impl ConfigurationDiagnostic {
7280
message: MessageAndDescription::from(markup! {{message}}.to_owned()),
7381
})
7482
}
83+
84+
pub fn cant_resolve(path: impl Display, source: oxc_resolver::ResolveError) -> Self {
85+
Self::CantResolve(CantResolve {
86+
message: MessageAndDescription::from(
87+
markup! {
88+
"Failed to resolve the configuration from "{{path}}
89+
}
90+
.to_owned(),
91+
),
92+
source: Some(Error::from(ResolveError::from(source))),
93+
})
94+
}
7595
}
7696

7797
impl Debug for ConfigurationDiagnostic {
@@ -168,3 +188,36 @@ pub struct CantResolve {
168188
#[source]
169189
source: Option<Error>,
170190
}
191+
192+
#[derive(Debug, Serialize, Deserialize, Diagnostic)]
193+
#[diagnostic(
194+
category = "configuration",
195+
severity = Error,
196+
)]
197+
pub struct CantLoadExtendFile {
198+
#[location(resource)]
199+
file_path: String,
200+
#[message]
201+
#[description]
202+
message: MessageAndDescription,
203+
204+
#[verbose_advice]
205+
verbose_advice: ConfigurationAdvices,
206+
}
207+
208+
impl CantLoadExtendFile {
209+
pub fn new(file_path: impl Into<String>, message: impl Display) -> Self {
210+
Self {
211+
file_path: file_path.into(),
212+
message: MessageAndDescription::from(markup! {{message}}.to_owned()),
213+
verbose_advice: ConfigurationAdvices::default(),
214+
}
215+
}
216+
217+
pub fn with_verbose_advice(mut self, messsage: impl Display) -> Self {
218+
self.verbose_advice
219+
.messages
220+
.push(markup! {{messsage}}.to_owned());
221+
self
222+
}
223+
}

crates/pgt_configuration/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use analyser::{
2222
RulePlainConfiguration, RuleSelector, RuleWithFixOptions, RuleWithOptions, Rules,
2323
partial_linter_configuration,
2424
};
25+
use biome_deserialize::StringSet;
2526
use biome_deserialize_macros::{Merge, Partial};
2627
use bpaf::Bpaf;
2728
use database::{
@@ -50,6 +51,10 @@ pub struct Configuration {
5051
#[partial(bpaf(hide))]
5152
pub schema: String,
5253

54+
/// A list of paths to other JSON files, used to extends the current configuration.
55+
#[partial(bpaf(hide))]
56+
pub extends: StringSet,
57+
5358
/// The configuration of the VCS integration
5459
#[partial(type, bpaf(external(partial_vcs_configuration), optional, hide_usage))]
5560
pub vcs: VcsConfiguration,
@@ -85,6 +90,7 @@ impl PartialConfiguration {
8590
pub fn init() -> Self {
8691
Self {
8792
schema: Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json")),
93+
extends: Some(StringSet::default()),
8894
files: Some(PartialFilesConfiguration {
8995
ignore: Some(Default::default()),
9096
..Default::default()

crates/pgt_diagnostics/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ version = "0.0.0"
1515
backtrace = "0.3.74"
1616
bpaf = { workspace = true }
1717
enumflags2 = { workspace = true }
18+
oxc_resolver = { workspace = true }
1819
pgt_console = { workspace = true, features = ["serde"] }
1920
pgt_diagnostics_categories = { workspace = true, features = ["serde"] }
2021
pgt_diagnostics_macros = { workspace = true }

0 commit comments

Comments
 (0)