Skip to content

Commit

Permalink
Revert "Add setting to opt in to private variables"
Browse files Browse the repository at this point in the history
This reverts commit 4f2128f.
  • Loading branch information
adsnaider committed Aug 10, 2024
1 parent a4a693d commit f6c0842
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion src/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub(crate) enum Keyword {
Alias,
AllowDuplicateRecipes,
AllowDuplicateVariables,
AllowPrivateVariables,
Assert,
DotenvFilename,
DotenvLoad,
Expand Down
1 change: 0 additions & 1 deletion src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?)),
Expand Down
2 changes: 0 additions & 2 deletions src/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>),
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub(crate) dotenv_load: bool,
pub(crate) dotenv_path: Option<PathBuf>,
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions tests/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ test! {
test! {
name: evaluate_private,
justfile: "
set allow-private-variables
[private]
foo := 'one'
bar := 'two'
Expand All @@ -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'
Expand Down
22 changes: 0 additions & 22 deletions tests/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
41 changes: 3 additions & 38 deletions tests/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -85,8 +71,6 @@ test! {
test! {
name: allows_implicit_private_overrides,
justfile: "
set allow-private-variables
[private]
foo := 'one'
bar := 'two'
Expand All @@ -103,8 +87,6 @@ test! {
test! {
name: allowed_public_overrides,
justfile: "
set allow-private-variables
[private]
foo := 'one'
bar := 'two'
Expand All @@ -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,
}

0 comments on commit f6c0842

Please sign in to comment.