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

Implemented 'set allow-duplicate-variables' #1922

Merged
merged 12 commits into from
May 15, 2024

Conversation

Mijago
Copy link
Contributor

@Mijago Mijago commented Feb 21, 2024

I ran into the same issue as #1827 and decided to make a quick draft for it.
It's my first rodeo with rust (and I am not a big fan so far, but it may grow onto me), so I appreciate feedback.

This issue allows us to overwrite assignments, even when they are imported from other justfiles. Previously it would have thrown an error. We now can use set allow-duplicate-variables to enable this behavior (in the same style as the existing set allow-duplicate-recipes).

Example: Default behavior

a := "foo"
a := "bar" 
#  Example: Raises an exception

Example: Using the flag to overwrite a variable

set allow-duplicate-variables

a := "foo"
a := "bar"
# a is now "bar"

Example: Using the flag in an import

# imp.just
a := "foo"
# some.just
import "./imp.just"
set allow-duplicate-variables

a := "bar"
# a is now "bar"

Feedback appreciated

I am not quite happy with the detour I had to take with DepthAwareBinding. I introduced it because the assignments need to be aware of their depth, otherwise imported modules would overwrite assignments that appear later in the justfile. As I did not use rust before, I do not know the best practices for this in this language and just wanted to get the draft done (for now).

Some other thing

I ran into just just (hehe) a few months ago - and fell in love. Thanks for this tool!

@Mijago
Copy link
Contributor Author

Mijago commented Mar 1, 2024

@casey Hi! I do not want to come off rude or impatient - but is there anything I should change in order to progress this PR further?

@casey
Copy link
Owner

casey commented May 15, 2024

Sorry for letting this sit! This looks great. I made a couple changes:

  • I removed DepthAwareBinding and just added a depth, which is set to 0 when not needed, to Binding.
  • I removed the modules_use_module_settings_variables test. Since there is no code specific to different settings which implements this, I don't think a new test is needed for each setting.

@casey casey enabled auto-merge (squash) May 15, 2024 01:36
@casey casey merged commit e116840 into casey:master May 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants