Skip to content

Commit bcfddaf

Browse files
committed
chore: merge main
2 parents 835f90a + ee0e583 commit bcfddaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1031
-726
lines changed

.cargo/config.toml

-3
This file was deleted.

.github/workflows/pull_request.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
env:
23-
RUSTFLAGS: -A dead_code
2423
RUST_LOG: info
2524
RUST_BACKTRACE: 1
2625
RUSTUP_WINDOWS_PATH_ADD_BIN: 1

.github/workflows/release.yml

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ permissions:
77
contents: write
88

99
env:
10-
# Ultimately, we shouldn't ignore warnings.
11-
# We need to pass it as an ENV because inlining doesn't work on Windows.
12-
RUSTFLAGS: -A dead_code
1310
# Need these guys for cross-compilation
1411
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
1512
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"postgrestools.bin": "./target/debug/postgrestools"
3+
}

Cargo.lock

+33-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ serde = "1.0.195"
3939
serde_json = "1.0.114"
4040
similar = "2.6.0"
4141
smallvec = { version = "1.13.2", features = ["union", "const_new", "serde"] }
42+
strum = { version = "0.27.1", features = ["derive"] }
4243
# this will use tokio if available, otherwise async-std
4344
sqlx = { version = "0.8.2", features = ["runtime-tokio", "runtime-async-std", "postgres", "json"] }
4445
syn = "1.0.109"
@@ -57,7 +58,6 @@ pgt_analyse = { path = "./crates/pgt_analyse", version = "0.0.0"
5758
pgt_analyser = { path = "./crates/pgt_analyser", version = "0.0.0" }
5859
pgt_base_db = { path = "./crates/pgt_base_db", version = "0.0.0" }
5960
pgt_cli = { path = "./crates/pgt_cli", version = "0.0.0" }
60-
pgt_commands = { path = "./crates/pgt_commands", version = "0.0.0" }
6161
pgt_completions = { path = "./crates/pgt_completions", version = "0.0.0" }
6262
pgt_configuration = { path = "./crates/pgt_configuration", version = "0.0.0" }
6363
pgt_console = { path = "./crates/pgt_console", version = "0.0.0" }

crates/pgt_analyse/src/rule.rs

-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ impl RuleDiagnostic {
260260
self.footer(LogCategory::Warn, msg)
261261
}
262262

263-
pub(crate) fn span(&self) -> Option<TextRange> {
264-
self.span
265-
}
266-
267263
pub fn advices(&self) -> &RuleAdvice {
268264
&self.rule_advice
269265
}

crates/pgt_cli/src/commands/check.rs

-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ impl CommandRunner for CheckCommandPayload {
6161
self.stdin_file_path.as_deref()
6262
}
6363

64-
fn should_write(&self) -> bool {
65-
false
66-
}
67-
6864
fn get_execution(
6965
&self,
7066
cli_options: &CliOptions,

crates/pgt_cli/src/commands/daemon.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
use pgt_console::{ConsoleExt, markup};
66
use pgt_lsp::ServerFactory;
77
use pgt_workspace::{TransportError, WorkspaceError, workspace::WorkspaceClient};
8-
use std::{env, fs, path::PathBuf};
8+
use std::{env, path::PathBuf};
99
use tokio::io;
1010
use tokio::runtime::Runtime;
1111
use tracing::subscriber::Interest;
@@ -175,33 +175,6 @@ async fn start_lsp_proxy(
175175
}
176176
}
177177

178-
pub(crate) fn read_most_recent_log_file(
179-
log_path: Option<PathBuf>,
180-
log_file_name_prefix: String,
181-
) -> io::Result<Option<String>> {
182-
let pgt_log_path = log_path.unwrap_or(default_pgt_log_path());
183-
184-
let most_recent = fs::read_dir(pgt_log_path)?
185-
.flatten()
186-
.filter(|file| file.file_type().is_ok_and(|ty| ty.is_file()))
187-
.filter_map(|file| {
188-
match file
189-
.file_name()
190-
.to_str()?
191-
.split_once(log_file_name_prefix.as_str())
192-
{
193-
Some((_, date_part)) if date_part.split('-').count() == 4 => Some(file.path()),
194-
_ => None,
195-
}
196-
})
197-
.max();
198-
199-
match most_recent {
200-
Some(file) => Ok(Some(fs::read_to_string(file)?)),
201-
None => Ok(None),
202-
}
203-
}
204-
205178
/// Set up the [tracing]-based logging system for the server
206179
/// The events received by the subscriber are filtered at the `info` level,
207180
/// then printed using the [HierarchicalLayer] layer, and the resulting text

crates/pgt_cli/src/commands/mod.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use pgt_workspace::workspace::UpdateSettingsParams;
1515
use pgt_workspace::{DynRef, Workspace, WorkspaceError};
1616
use std::ffi::OsString;
1717
use std::path::PathBuf;
18-
1918
pub(crate) mod check;
2019
pub(crate) mod clean;
2120
pub(crate) mod daemon;
@@ -24,6 +23,7 @@ pub(crate) mod version;
2423

2524
#[derive(Debug, Clone, Bpaf)]
2625
#[bpaf(options, version(VERSION))]
26+
#[allow(clippy::large_enum_variant)]
2727
/// Postgres Tools official CLI. Use it to check the health of your project or run it to check single files.
2828
pub enum PgtCommand {
2929
/// Shows the version information and quit.
@@ -338,9 +338,6 @@ pub(crate) trait CommandRunner: Sized {
338338
/// It returns the file path to use in `stdin` mode.
339339
fn get_stdin_file_path(&self) -> Option<&str>;
340340

341-
/// Whether the command should write the files.
342-
fn should_write(&self) -> bool;
343-
344341
/// Returns the [Execution] mode.
345342
fn get_execution(
346343
&self,
@@ -357,11 +354,6 @@ pub(crate) trait CommandRunner: Sized {
357354
fn check_incompatible_arguments(&self) -> Result<(), CliDiagnostic> {
358355
Ok(())
359356
}
360-
361-
/// Checks whether the configuration has errors.
362-
fn should_validate_configuration_diagnostics(&self) -> bool {
363-
true
364-
}
365357
}
366358

367359
fn get_files_to_process_with_cli_options(

crates/pgt_cli/src/diagnostics.rs

-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use pgt_console::fmt::Display;
21
use pgt_console::markup;
32
use pgt_diagnostics::adapters::{BpafError, IoError, SerdeJsonError};
43
use pgt_diagnostics::{
@@ -231,25 +230,6 @@ pub struct IncompatibleEndConfiguration {
231230
)]
232231
pub struct NoFilesWereProcessed;
233232

234-
#[derive(Debug, Diagnostic)]
235-
#[diagnostic(
236-
category = "internalError/fs",
237-
severity = Warning,
238-
tags(DEPRECATED_CODE)
239-
)]
240-
pub struct DeprecatedArgument {
241-
#[message]
242-
pub message: MessageAndDescription,
243-
}
244-
245-
impl DeprecatedArgument {
246-
pub fn new(message: impl Display) -> Self {
247-
Self {
248-
message: MessageAndDescription::from(markup! {{message}}.to_owned()),
249-
}
250-
}
251-
}
252-
253233
#[derive(Debug, Diagnostic)]
254234
pub enum ReportDiagnostic {
255235
/// Emitted when trying to serialise the report

crates/pgt_cli/src/execute/diagnostics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub(crate) trait ResultExt {
1919
code: &'static Category,
2020
) -> Result<Self::Result, Error>;
2121

22+
#[allow(unused)]
2223
fn with_file_path_and_code_and_tags(
2324
self,
2425
file_path: String,

crates/pgt_cli/src/execute/mod.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use crate::reporter::junit::{JunitReporter, JunitReporterVisitor};
1111
use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor};
1212
use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter};
1313
use pgt_diagnostics::{Category, category};
14-
use pgt_fs::PgTPath;
1514
use std::borrow::Borrow;
1615
use std::ffi::OsString;
1716
use std::fmt::{Display, Formatter};
18-
use std::path::{Path, PathBuf};
17+
use std::path::PathBuf;
1918
use tracing::info;
2019

2120
/// Useful information during the traversal of files and virtual content
@@ -37,25 +36,17 @@ impl Execution {
3736
}
3837
}
3938

40-
#[derive(Debug, Clone, Copy)]
41-
pub enum ExecutionEnvironment {
42-
GitHub,
43-
}
44-
4539
/// A type that holds the information to execute the CLI via `stdin
4640
#[derive(Debug, Clone)]
4741
pub struct Stdin(
42+
#[allow(unused)]
4843
/// The virtual path to the file
4944
PathBuf,
5045
/// The content of the file
5146
String,
5247
);
5348

5449
impl Stdin {
55-
fn as_path(&self) -> &Path {
56-
self.0.as_path()
57-
}
58-
5950
fn as_content(&self) -> &str {
6051
self.1.as_str()
6152
}
@@ -170,10 +161,6 @@ impl Execution {
170161
}
171162
}
172163

173-
pub(crate) const fn is_dummy(&self) -> bool {
174-
matches!(self.traversal_mode, TraversalMode::Dummy)
175-
}
176-
177164
/// Whether the traversal mode requires write access to files
178165
pub(crate) const fn requires_write_access(&self) -> bool {
179166
match self.traversal_mode {
@@ -202,6 +189,7 @@ impl Execution {
202189
false
203190
}
204191

192+
#[allow(unused)]
205193
/// Returns [true] if the user used the `--write`/`--fix` option
206194
pub(crate) fn is_write(&self) -> bool {
207195
match self.traversal_mode {
@@ -232,14 +220,7 @@ pub fn execute_mode(
232220

233221
// don't do any traversal if there's some content coming from stdin
234222
if let Some(stdin) = execution.as_stdin_file() {
235-
let pgt_path = PgTPath::new(stdin.as_path());
236-
std_in::run(
237-
session,
238-
&execution,
239-
pgt_path,
240-
stdin.as_content(),
241-
cli_options.verbose,
242-
)
223+
std_in::run(session, stdin.as_content())
243224
} else {
244225
let TraverseResult {
245226
summary,

0 commit comments

Comments
 (0)