From 20b4bf156ba308bab561f47635e2d0789465ebea Mon Sep 17 00:00:00 2001 From: Matthew Davidson Date: Thu, 29 Sep 2022 20:53:25 +0800 Subject: [PATCH 1/6] docs(java): Fix typo in file detection list (#4416) Fix typo in docs for Java identification. The file is "deps.edn", not ".deps.edn" (with a dot at the beginning). The code looks for the correct name, the typo is only in the docs. --- docs/config/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/config/README.md b/docs/config/README.md index 85ddd0d18..469eac737 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -1952,21 +1952,21 @@ disabled = false The `java` module shows the currently installed version of [Java](https://www.oracle.com/java/). By default the module will be shown if any of the following conditions are met: -- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `.deps.edn`, `project.clj`, or `build.boot` file +- The current directory contains a `pom.xml`, `build.gradle.kts`, `build.sbt`, `.java-version`, `deps.edn`, `project.clj`, or `build.boot` file - The current directory contains a file with the `.java`, `.class`, `.gradle`, `.jar`, `.clj`, or `.cljc` extension ### Options -| Option | Default | Description | -| ------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. | -| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `detect_extensions` | `["java", "class", "gradle", "jar", "cljs", "cljc"]` | Which extensions should trigger this module. | -| `detect_files` | `["pom.xml", "build.gradle.kts", "build.sbt", ".java-version", ".deps.edn", "project.clj", "build.boot"]` | Which filenames should trigger this module. | -| `detect_folders` | `[]` | Which folders should trigger this modules. | -| `symbol` | `"☕ "` | A format string representing the symbol of Java | -| `style` | `"red dimmed"` | The style for the module. | -| `disabled` | `false` | Disables the `java` module. | +| Option | Default | Description | +| ------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. | +| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | +| `detect_extensions` | `["java", "class", "gradle", "jar", "cljs", "cljc"]` | Which extensions should trigger this module. | +| `detect_files` | `["pom.xml", "build.gradle.kts", "build.sbt", ".java-version", "deps.edn", "project.clj", "build.boot"]` | Which filenames should trigger this module. | +| `detect_folders` | `[]` | Which folders should trigger this modules. | +| `symbol` | `"☕ "` | A format string representing the symbol of Java | +| `style` | `"red dimmed"` | The style for the module. | +| `disabled` | `false` | Disables the `java` module. | ### Variables From c5bffb56201207b2c333226752a7580a199d2f2e Mon Sep 17 00:00:00 2001 From: David Knaack Date: Thu, 29 Sep 2022 23:51:56 +0200 Subject: [PATCH 2/6] build: bump clap from v3 to v4 (#4413) * build: bump clap from v3 to v4 * bump --- Cargo.lock | 28 +++++++++------------------- Cargo.toml | 6 +++--- src/main.rs | 4 ++-- src/print.rs | 4 ++-- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd8f0122e..d35474b2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,36 +323,35 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.22" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "31c9484ccdc4cb8e7b117cbd0eb150c7c0f04464854e4679aeb50ef03b32d003" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap", "unicase", + "unicode-width", ] [[package]] name = "clap_complete" -version = "3.2.5" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f7a2e0a962c45ce25afce14220bc24f9dade0a1787f185cecf96bfba7847cd8" +checksum = "f04c8f8007e8a1813ba933df2d8fb50cad04e0d9e89a22d64485f25a6a6c35d8" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "ca689d7434ce44517a12a89456b2be4d1ea1cafcd8f581978c03d45f5a5c12a7" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -363,9 +362,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] @@ -2997,15 +2996,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.35" diff --git a/Cargo.toml b/Cargo.toml index 89acaf4f8..3f95317c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ license = "ISC" readme = "README.md" repository = "https://github.com/starship/starship" # Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship. -rust-version = "1.59" +rust-version = "1.60" description = """ The minimal, blazing-fast, and infinitely customizable prompt for any shell! ☄🌌️ """ @@ -36,8 +36,8 @@ notify = ["notify-rust"] [dependencies] chrono = { version = "0.4.22", features = ["clock", "std"] } -clap = { version = "=3.2.22", features = ["derive", "cargo", "unicode", "unstable-v4"] } -clap_complete = "3.2.5" +clap = { version = "4.0.2", features = ["derive", "cargo", "unicode"] } +clap_complete = "4.0.1" dirs-next = "2.0.0" dunce = "1.0.2" gethostname = "0.2.3" diff --git a/src/main.rs b/src/main.rs index 7ffb15887..80830f985 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ use std::io; use std::thread::available_parallelism; use std::time::SystemTime; -use clap::{IntoApp, Parser, Subcommand}; +use clap::{CommandFactory, Parser, Subcommand}; use clap_complete::{generate, Shell as CompletionShell}; use rand::distributions::Alphanumeric; use rand::Rng; @@ -33,7 +33,7 @@ enum Commands { BugReport, /// Generate starship shell completions for your shell to stdout Completions { - #[clap(arg_enum)] + #[clap(value_enum)] shell: CompletionShell, }, /// Edit the starship configuration diff --git a/src/print.rs b/src/print.rs index aed249d91..6bb1f1be7 100644 --- a/src/print.rs +++ b/src/print.rs @@ -1,4 +1,4 @@ -use clap::{PossibleValue, ValueEnum}; +use clap::{builder::PossibleValue, ValueEnum}; use nu_ansi_term::AnsiStrings; use rayon::prelude::*; use std::collections::BTreeSet; @@ -460,7 +460,7 @@ impl ValueEnum for Preset { shadow::get_preset_list() } - fn to_possible_value<'a>(&self) -> Option> { + fn to_possible_value(&self) -> Option { Some(PossibleValue::new(self.0)) } } From 98996f584618bbc2632b883ee49bc38a1e3f7217 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:02:50 +0200 Subject: [PATCH 3/6] build: bump clap from 4.0.2 to 4.0.4 (#4422) Bumps [clap](https://github.com/clap-rs/clap) from 4.0.2 to 4.0.4. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.0.2...v4.0.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d35474b2a..1c4658b1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,9 +323,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.2" +version = "4.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9484ccdc4cb8e7b117cbd0eb150c7c0f04464854e4679aeb50ef03b32d003" +checksum = "7f78ad8e84aa8e8aa3e821857be40eb4b925ff232de430d4dd2ae6aa058cbd92" dependencies = [ "atty", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 3f95317c0..a409b703c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ notify = ["notify-rust"] [dependencies] chrono = { version = "0.4.22", features = ["clock", "std"] } -clap = { version = "4.0.2", features = ["derive", "cargo", "unicode"] } +clap = { version = "4.0.4", features = ["derive", "cargo", "unicode"] } clap_complete = "4.0.1" dirs-next = "2.0.0" dunce = "1.0.2" From 801fbab720e1bb94c32bb1aa10966a0637a10e63 Mon Sep 17 00:00:00 2001 From: ccQpein Date: Fri, 30 Sep 2022 05:03:33 -0400 Subject: [PATCH 4/6] fix(directory): don't strip duplicate directory names twice (#4295) * Fix directory issue in a special case * add None test --- src/modules/directory.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/modules/directory.rs b/src/modules/directory.rs index be778bb00..ca703ab7c 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -111,7 +111,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { || ((num_segments_after_root - 1) as i64) < config.truncation_length { let root = repo_path_vec[0]; - let before = dir_string.replace(&contracted_path, ""); + let before = before_root_dir(&dir_string, &contracted_path); [prefix + before.as_str(), root.to_string(), after_repo_root] } else { ["".to_string(), "".to_string(), prefix + dir_string.as_str()] @@ -339,6 +339,14 @@ fn convert_path_sep(path: &str) -> String { return PathBuf::from_slash(path).to_string_lossy().into_owned(); } +/// Get the path before the git repo root by trim the most right repo name. +fn before_root_dir(path: &str, repo: &str) -> String { + match path.rsplit_once(repo) { + Some((a, _)) => a.to_string(), + None => path.to_string(), + } +} + #[cfg(test)] mod tests { use super::*; @@ -1788,4 +1796,22 @@ mod tests { assert_eq!(expected, actual); tmp_dir.close() } + + #[test] + fn parent_and_sub_git_repo_are_in_same_name_folder() { + assert_eq!( + before_root_dir("~/user/gitrepo/gitrepo", "gitrepo"), + "~/user/gitrepo/".to_string() + ); + + assert_eq!( + before_root_dir("~/user/gitrepo-diff/gitrepo", "gitrepo"), + "~/user/gitrepo-diff/".to_string() + ); + + assert_eq!( + before_root_dir("~/user/gitrepo-diff/gitrepo", "aaa"), + "~/user/gitrepo-diff/gitrepo".to_string() + ); + } } From 976e62a071d04e20f9c8a0852f65cb3cd98deaed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 12:41:30 +0200 Subject: [PATCH 5/6] build: bump clap_complete from 4.0.1 to 4.0.2 (#4420) Bumps [clap_complete](https://github.com/clap-rs/clap) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.0.1...clap_complete-v4.0.2) --- updated-dependencies: - dependency-name: clap_complete dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c4658b1e..f28245b1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.0.1" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04c8f8007e8a1813ba933df2d8fb50cad04e0d9e89a22d64485f25a6a6c35d8" +checksum = "11cba7abac9b56dfe2f035098cdb3a43946f276e6db83b72c4e692343f9aab9a" dependencies = [ "clap", ] diff --git a/Cargo.toml b/Cargo.toml index a409b703c..4cdd635ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ notify = ["notify-rust"] [dependencies] chrono = { version = "0.4.22", features = ["clock", "std"] } clap = { version = "4.0.4", features = ["derive", "cargo", "unicode"] } -clap_complete = "4.0.1" +clap_complete = "4.0.2" dirs-next = "2.0.0" dunce = "1.0.2" gethostname = "0.2.3" From da927e4aaa3329a7e5c3bfc53dc4641e525c3022 Mon Sep 17 00:00:00 2001 From: Sagar <42873729+sagarkrp@users.noreply.github.com> Date: Sun, 2 Oct 2022 23:20:38 +0530 Subject: [PATCH 6/6] docs: duplicate installation instruction for Nixos in readme (#4433) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2231f8b6a..8ac2cc13d 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,6 @@ Alternatively, install Starship using any of the following package managers: | Arch Linux | [Arch Linux Community] | `pacman -S starship` | | CentOS 7+ | [Copr] | `dnf copr enable atim/starship`
`dnf install starship` | | Fedora 31+ | [Fedora Packages] | `dnf install starship` | -| NixOS | [nixpkgs] | `nix-env -iA nixos.starship` | | Gentoo | [Gentoo Packages] | `emerge app-shells/starship` | | Manjaro | | `pacman -S starship` | | NixOS | [nixpkgs] | `nix-env -iA nixpkgs.starship` |