diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8f987c01c0..c4ca8971d2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -69,9 +69,14 @@ jobs: run: | rustup target add aarch64-pc-windows-msvc - - name: Ref Type - id: ref-type - run: cargo run --package ref-type -- --reference ${{ github.ref }} >> $GITHUB_OUTPUT + - name: Release Type + id: release-type + run: | + if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+[.][0-9]+[.][0-9]+$ ]]; then + echo value=release >> $GITHUB_OUTPUT + else + echo value=prerelease >> $GITHUB_OUTPUT + fi - name: Generate Completion Scripts and Manpage run: | @@ -102,7 +107,7 @@ jobs: files: | ${{ steps.package.outputs.archive }} ${{ steps.package.outputs.archive }}.sha256sum - prerelease: ${{ steps.ref-type.outputs.value != 'release' }} + prerelease: ${{ steps.release-type.outputs.value == 'prerelease' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index ace617a59b..ec444d074b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,29 +96,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -213,21 +196,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.5.16" @@ -247,7 +215,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", "terminal_size", ] @@ -257,7 +225,7 @@ version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b" dependencies = [ - "clap 4.5.16", + "clap", ] [[package]] @@ -266,7 +234,7 @@ version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.76", @@ -284,7 +252,7 @@ version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17415fd4dfbea46e3274fcd8d368284519b358654772afb700dc2e8d2b24eeb" dependencies = [ - "clap 4.5.16", + "clap", "roff", ] @@ -486,30 +454,12 @@ dependencies = [ "wasi", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -577,7 +527,7 @@ dependencies = [ "blake3", "camino", "chrono", - "clap 4.5.16", + "clap", "clap_complete", "clap_mangen", "ctrlc", @@ -586,7 +536,7 @@ dependencies = [ "dotenvy", "edit-distance", "executable-path", - "heck 0.5.0", + "heck", "lexiclean", "libc", "num_cpus", @@ -612,12 +562,6 @@ dependencies = [ "which", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "lexiclean" version = "0.0.1" @@ -636,7 +580,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags", "libc", ] @@ -673,7 +617,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "cfg_aliases", "libc", @@ -694,7 +638,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -735,30 +679,6 @@ dependencies = [ "yansi", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -774,7 +694,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" dependencies = [ - "bitflags 2.6.0", + "bitflags", "getopts", "memchr", "unicase", @@ -849,15 +769,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "ref-type" -version = "0.0.0" -dependencies = [ - "executable-path", - "regex", - "structopt", -] - [[package]] name = "regex" version = "1.10.6" @@ -899,7 +810,7 @@ version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1007,48 +918,18 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d1e02fca405f6280643174a50c942219f0bbf4dbf7d480f1dd864d6f211ae5" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.76", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "strum" version = "0.26.3" @@ -1064,7 +945,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -1131,15 +1012,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.63" @@ -1221,12 +1093,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.5" diff --git a/README.md b/README.md index e9e75c70a2..420bbcb9d5 100644 --- a/README.md +++ b/README.md @@ -905,6 +905,9 @@ are set, `just` will try to load environment variables from a file. If `dotenv-path` is set, `just` will look for a file at the given path, which may be absolute, or relative to the working directory. +The command-line option `--dotenv-path`, short form `-E`, can be used to set or +override `dotenv-path` at runtime. + If `dotenv-filename` is set `just` will look for a file at the given path, relative to the working directory and each of its ancestors. diff --git a/crates/ref-type/Cargo.toml b/crates/ref-type/Cargo.toml deleted file mode 100644 index bdc99c43fc..0000000000 --- a/crates/ref-type/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "ref-type" -version = "0.0.0" -authors = ["Casey Rodarmor "] -edition = "2018" -publish = false - -[dependencies] -regex = "1.5.4" -structopt = "0.3.21" - -[dev-dependencies] -executable-path = "1.0.0" diff --git a/crates/ref-type/src/main.rs b/crates/ref-type/src/main.rs deleted file mode 100644 index 963d1356d8..0000000000 --- a/crates/ref-type/src/main.rs +++ /dev/null @@ -1,25 +0,0 @@ -use {regex::Regex, structopt::StructOpt}; - -#[derive(StructOpt)] -struct Arguments { - #[structopt(long)] - reference: String, -} - -fn main() { - let arguments = Arguments::from_args(); - - let regex = Regex::new("^refs/tags/[[:digit:]]+[.][[:digit:]]+[.][[:digit:]]+$") - .expect("Failed to compile release regex"); - - let value = if regex.is_match(&arguments.reference) { - "release" - } else { - "other" - }; - - eprintln!("ref: {}", arguments.reference); - eprintln!("value: {value}"); - - println!("value={value}"); -} diff --git a/crates/ref-type/tests/integration.rs b/crates/ref-type/tests/integration.rs deleted file mode 100644 index 99b378cf22..0000000000 --- a/crates/ref-type/tests/integration.rs +++ /dev/null @@ -1,38 +0,0 @@ -use { - executable_path::executable_path, - std::{process::Command, str}, -}; - -fn stdout(reference: &str) -> String { - let output = Command::new(executable_path("ref-type")) - .args(["--reference", reference]) - .output() - .unwrap(); - - assert!(output.status.success()); - - String::from_utf8(output.stdout).unwrap() -} - -#[test] -fn junk_is_other() { - assert_eq!(stdout("refs/tags/asdf"), "value=other\n"); -} - -#[test] -fn valid_version_is_release() { - assert_eq!(stdout("refs/tags/0.0.0"), "value=release\n"); -} - -#[test] -fn valid_version_with_trailing_characters_is_other() { - assert_eq!(stdout("refs/tags/0.0.0-rc1"), "value=other\n"); -} - -#[test] -fn valid_version_with_lots_of_digits_is_release() { - assert_eq!( - stdout("refs/tags/01232132.098327498374.43268473849734"), - "value=release\n" - ); -} diff --git a/justfile b/justfile index 9681aecd7d..77a6a60c43 100755 --- a/justfile +++ b/justfile @@ -4,8 +4,6 @@ alias t := test -alias c := check - log := "warn" export JUST_LOG := log @@ -14,14 +12,9 @@ watch +args='test': cargo watch --clear --exec '{{ args }}' test: - cargo test - -ci: lint build-book cargo test --all -lint: - cargo clippy --all --all-targets -- --deny warnings - ./bin/forbid +ci: forbid test build-book clippy cargo fmt --all -- --check cargo update --locked --package just @@ -59,13 +52,6 @@ update-changelog: update-contributors: cargo run --release --package update-contributors -check: fmt clippy test forbid - #!/usr/bin/env bash - set -euxo pipefail - git diff --no-ext-diff --quiet --exit-code - VERSION=`sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1` - grep "^\[$VERSION\]" CHANGELOG.md - outdated: cargo outdated -R @@ -87,13 +73,6 @@ publish: readme-version-notes: grep 'master' README.md -push: check - ! git branch | grep '* master' - git push github - -pr: push - gh pr create --web - # clean up feature branch BRANCH done BRANCH=`git rev-parse --abbrev-ref HEAD`: git checkout master @@ -117,15 +96,11 @@ install-dev-deps: # everyone's favorite animate paper clip clippy: - cargo clippy --all --all-targets --all-features + cargo clippy --all --all-targets --all-features -- --deny warnings forbid: ./bin/forbid -# count non-empty lines of code -sloc: - @cat src/*.rs | sed '/^\s*$/d' | wc -l - replace FROM TO: sd '{{FROM}}' '{{TO}}' src/*.rs @@ -160,16 +135,6 @@ quine-text := ' } ' -render-readme: - #!/usr/bin/env ruby - require 'github/markup' - $rendered = GitHub::Markup.render("README.adoc", File.read("README.adoc")) - File.write('tmp/README.html', $rendered) - -watch-readme: - just render-readme - fswatch -ro README.adoc | xargs -n1 -I{} just render-readme - test-completions: ./tests/completions/just.bash @@ -178,17 +143,6 @@ build-book: mdbook build book/en mdbook build book/zh -convert-integration-test test: - cargo expand --test integration {{test}} | \ - sed \ - -E \ - -e 's/#\[cfg\(test\)\]/#\[test\]/' \ - -e 's/^ *let test = //' \ - -e 's/^ *test[.]/./' \ - -e 's/;$//' \ - -e 's/crate::test::Test/Test/' \ - -e 's/\.run\(\)/.run();/' - # run all polyglot recipes polyglot: _python _js _perl _sh _ruby diff --git a/src/analyzer.rs b/src/analyzer.rs index de023c41ba..8a6b8eed36 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -52,10 +52,10 @@ impl<'src> Analyzer<'src> { -> CompileResult<'src> { if let Some((first_type, original)) = definitions.get(name.lexeme()) { if !(*first_type == second_type && duplicates_allowed) { - let (original, redefinition) = if name.line < original.line { - (name, *original) + let ((first_type, second_type), (original, redefinition)) = if name.line < original.line { + ((second_type, *first_type), (name, *original)) } else { - (*original, name) + ((*first_type, second_type), (*original, name)) }; return Err(redefinition.token.error(Redefinition { @@ -383,7 +383,7 @@ mod tests { line: 2, column: 6, width: 3, - kind: Redefinition { first_type: "alias", second_type: "recipe", name: "foo", first: 0 }, + kind: Redefinition { first_type: "recipe", second_type: "alias", name: "foo", first: 0 }, } analysis_error! { diff --git a/tests/error_messages.rs b/tests/error_messages.rs index 5b66ac3cb9..cc7515fb02 100644 --- a/tests/error_messages.rs +++ b/tests/error_messages.rs @@ -109,3 +109,21 @@ fn file_paths_not_in_subdir_are_absolute() { ) .run(); } + +#[test] +fn redefinition_errors_properly_swap_types() { + Test::new() + .write("foo.just", "foo:") + .justfile("foo:\n echo foo\n\nmod foo 'foo.just'") + .status(EXIT_FAILURE) + .stderr( + " +error: Recipe `foo` defined on line 1 is redefined as a module on line 4 + ——▶ justfile:4:5 + │ +4 │ mod foo 'foo.just' + │ ^^^ +", + ) + .run(); +}