1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-10 12:22:21 +00:00
starship/src/configs/hg_branch.rs
Nicolas Évrard 8d2256ab1d
feat(hg_branch): Add support for mercurial topics and find hg root dir (#4771)
* feat(hg_branch): Add support for mercurial topics and find hg root dir

* Fix clippy errors

* Use crate::utils::read_file

* Update config-schema.json

* Extend PathExt to retrieve device ID of Path

* Break hg root search when switching to another device

* Fix clippy and formatting errors

* Update docs/config/README.md

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Update src/modules/utils/path.rs

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Update src/configs/hg_branch.rs

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Update hg_branch description

* Revert to lazy loading, use truncate_text from utils and use fake topic

* Format code and fix clippy error

* Revert to previous test string as topic is optional in the config

* Fix doc formatting

* Stub device_id for windows

* Update config-schema.json

* Update src/modules/hg_branch.rs

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>

* Do not use unwrap in device_id

* Fix formatter error

* Use dev under non linux unixes

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
2022-12-31 15:53:55 +01:00

31 lines
759 B
Rust

use serde::{Deserialize, Serialize};
#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct HgBranchConfig<'a> {
pub symbol: &'a str,
pub style: &'a str,
pub format: &'a str,
pub truncation_length: i64,
pub truncation_symbol: &'a str,
pub disabled: bool,
}
impl<'a> Default for HgBranchConfig<'a> {
fn default() -> Self {
HgBranchConfig {
symbol: "",
style: "bold purple",
format: "on [$symbol$branch(:$topic)]($style) ",
truncation_length: std::i64::MAX,
truncation_symbol: "",
disabled: true,
}
}
}