From 7b2f886d04b3c08412069d2b90b07425896ed249 Mon Sep 17 00:00:00 2001 From: Adam Snaider Date: Sat, 10 Aug 2024 13:37:56 -0400 Subject: [PATCH] Revert "Add setting to opt in to private variables" This reverts commit 4f2128f282216f4eb6ee94c0c351b02471328642. --- src/justfile.rs | 2 +- src/keyword.rs | 1 - src/node.rs | 1 - src/parser.rs | 3 --- src/setting.rs | 2 -- src/settings.rs | 4 ---- src/subcommand.rs | 3 +-- tests/evaluate.rs | 17 ----------------- tests/json.rs | 22 ---------------------- tests/private.rs | 41 +++-------------------------------------- 10 files changed, 5 insertions(+), 91 deletions(-) diff --git a/src/justfile.rs b/src/justfile.rs index 0f1b779836..c3b97acb9c 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -164,7 +164,7 @@ impl<'src> Justfile<'src> { let width = scope.names().fold(0, |max, name| name.len().max(max)); for binding in scope.bindings() { - if !self.settings.allow_private_variables || binding.is_public() { + if binding.is_public() { println!( "{0:1$} := \"{2}\"", binding.name.lexeme(), diff --git a/src/keyword.rs b/src/keyword.rs index 8091ee192d..ff06c39d27 100644 --- a/src/keyword.rs +++ b/src/keyword.rs @@ -6,7 +6,6 @@ pub(crate) enum Keyword { Alias, AllowDuplicateRecipes, AllowDuplicateVariables, - AllowPrivateVariables, Assert, DotenvFilename, DotenvLoad, diff --git a/src/node.rs b/src/node.rs index ca73e48e48..3ccf862d57 100644 --- a/src/node.rs +++ b/src/node.rs @@ -288,7 +288,6 @@ impl<'src> Node<'src> for Set<'src> { match &self.value { Setting::AllowDuplicateRecipes(value) | Setting::AllowDuplicateVariables(value) - | Setting::AllowPrivateVariables(value) | Setting::DotenvLoad(value) | Setting::DotenvRequired(value) | Setting::Export(value) diff --git a/src/parser.rs b/src/parser.rs index e0e8d577ce..0e69e70b01 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -948,9 +948,6 @@ impl<'run, 'src> Parser<'run, 'src> { Keyword::AllowDuplicateVariables => { Some(Setting::AllowDuplicateVariables(self.parse_set_bool()?)) } - Keyword::AllowPrivateVariables => { - Some(Setting::AllowPrivateVariables(self.parse_set_bool()?)) - } Keyword::DotenvLoad => Some(Setting::DotenvLoad(self.parse_set_bool()?)), Keyword::DotenvRequired => Some(Setting::DotenvRequired(self.parse_set_bool()?)), Keyword::Export => Some(Setting::Export(self.parse_set_bool()?)), diff --git a/src/setting.rs b/src/setting.rs index ecc9fceefe..2b68713580 100644 --- a/src/setting.rs +++ b/src/setting.rs @@ -4,7 +4,6 @@ use super::*; pub(crate) enum Setting<'src> { AllowDuplicateRecipes(bool), AllowDuplicateVariables(bool), - AllowPrivateVariables(bool), DotenvFilename(StringLiteral<'src>), DotenvLoad(bool), DotenvPath(StringLiteral<'src>), @@ -28,7 +27,6 @@ impl<'src> Display for Setting<'src> { match self { Self::AllowDuplicateRecipes(value) | Self::AllowDuplicateVariables(value) - | Self::AllowPrivateVariables(value) | Self::DotenvLoad(value) | Self::DotenvRequired(value) | Self::Export(value) diff --git a/src/settings.rs b/src/settings.rs index 443c6e7bc6..795ddebd1f 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -9,7 +9,6 @@ pub(crate) const WINDOWS_POWERSHELL_ARGS: &[&str] = &["-NoLogo", "-Command"]; pub(crate) struct Settings<'src> { pub(crate) allow_duplicate_recipes: bool, pub(crate) allow_duplicate_variables: bool, - pub(crate) allow_private_variables: bool, pub(crate) dotenv_filename: Option, pub(crate) dotenv_load: bool, pub(crate) dotenv_path: Option, @@ -41,9 +40,6 @@ impl<'src> Settings<'src> { Setting::AllowDuplicateVariables(allow_duplicate_variables) => { settings.allow_duplicate_variables = allow_duplicate_variables; } - Setting::AllowPrivateVariables(allow_private_variables) => { - settings.allow_private_variables = allow_private_variables; - } Setting::DotenvFilename(filename) => { settings.dotenv_filename = Some(filename.cooked); } diff --git a/src/subcommand.rs b/src/subcommand.rs index 5756c8faf6..cf1eaf1dc2 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -714,11 +714,10 @@ impl Subcommand { } fn public_variables(justfile: &Justfile) { - let filter_private = justfile.settings.allow_private_variables; for (i, (_, assignment)) in justfile .assignments .iter() - .filter(|(_, binding)| !filter_private || binding.is_public()) + .filter(|(_, binding)| binding.is_public()) .enumerate() { if i > 0 { diff --git a/tests/evaluate.rs b/tests/evaluate.rs index e7cf2eb822..110184c837 100644 --- a/tests/evaluate.rs +++ b/tests/evaluate.rs @@ -81,8 +81,6 @@ test! { test! { name: evaluate_private, justfile: " - set allow-private-variables - [private] foo := 'one' bar := 'two' @@ -93,24 +91,9 @@ test! { status: EXIT_SUCCESS, } -test! { - name: evaluate_private_not_enabled, - justfile: " - [private] - foo := 'one' - bar := 'two' - _baz := 'three' - ", - args: ("--evaluate"), - stdout: "_baz := \"three\"\nbar := \"two\"\nfoo := \"one\"\n", - status: EXIT_SUCCESS, -} - test! { name: evaluate_single_private, justfile: " - set allow-private-variables - [private] foo := 'one' bar := 'two' diff --git a/tests/json.rs b/tests/json.rs index ab3f187537..aa09dd87ad 100644 --- a/tests/json.rs +++ b/tests/json.rs @@ -47,7 +47,6 @@ fn alias() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -94,7 +93,6 @@ fn assignment() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -151,7 +149,6 @@ fn private_assignment() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -210,7 +207,6 @@ fn body() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -281,7 +277,6 @@ fn dependencies() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -391,7 +386,6 @@ fn dependency_argument() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -462,7 +456,6 @@ fn duplicate_recipes() { "settings": { "allow_duplicate_recipes": true, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -512,7 +505,6 @@ fn duplicate_variables() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": true, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -564,7 +556,6 @@ fn doc_comment() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -602,7 +593,6 @@ fn empty_justfile() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -761,7 +751,6 @@ fn parameters() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -853,7 +842,6 @@ fn priors() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -905,7 +893,6 @@ fn private() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -957,7 +944,6 @@ fn quiet() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1021,7 +1007,6 @@ fn settings() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": "filename", "dotenv_load": true, "dotenv_path": "path", @@ -1079,7 +1064,6 @@ fn shebang() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1131,7 +1115,6 @@ fn simple() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1186,7 +1169,6 @@ fn attribute() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1256,7 +1238,6 @@ fn module() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1281,7 +1262,6 @@ fn module() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1353,7 +1333,6 @@ fn module_group() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, @@ -1378,7 +1357,6 @@ fn module_group() { "settings": { "allow_duplicate_recipes": false, "allow_duplicate_variables": false, - "allow_private_variables": false, "dotenv_filename": null, "dotenv_load": false, "dotenv_path": null, diff --git a/tests/private.rs b/tests/private.rs index 2126868a83..96762b8050 100644 --- a/tests/private.rs +++ b/tests/private.rs @@ -42,33 +42,19 @@ fn private_attribute_for_alias() { test! { name: dont_list_private_variables, justfile: " - set allow-private-variables [private] foo := 'one' bar := 'two' _baz := 'three' ", - args: ("--variables"), - stdout: "bar\n", -} - -test! { - name: list_private_variables_if_not_opted_in, - justfile: " - [private] - foo := 'one' - bar := 'two' - _baz := 'three' - ", - args: ("--variables"), - stdout: "_baz bar foo\n", + args: ("--variables"), + stdout: "bar\n", + status: EXIT_SUCCESS, } test! { name: allows_private_overrides, justfile: " - set allow-private-variables - [private] foo := 'one' bar := 'two' @@ -85,8 +71,6 @@ test! { test! { name: allows_implicit_private_overrides, justfile: " - set allow-private-variables - [private] foo := 'one' bar := 'two' @@ -103,8 +87,6 @@ test! { test! { name: allowed_public_overrides, justfile: " - set allow-private-variables - [private] foo := 'one' bar := 'two' @@ -118,20 +100,3 @@ test! { stderr: "", status: EXIT_SUCCESS, } - -test! { - name: ignore_private_without_setting, - justfile: " - [private] - foo := 'one' - bar := 'two' - _baz := 'three' - - default: - @echo hello - ", - args: ("foo=two"), - stdout: "hello\n", - stderr: "", - status: EXIT_SUCCESS, -}