mirror of
https://github.com/nushell/nushell.git
synced 2025-06-20 09:58:15 +02:00
feat(gstat): add state
entry (like "Clean", "Merge", "Rebase", etc.) (#15965)
# Description This PR adds a new `state` key to the output of `gstat` that shows the current repo state state. Like "Clean", "Merge", "Rebase", etc. The full list of possible values can be seen [here](https://docs.rs/git2/latest/git2/enum.RepositoryState.html). This information is somewhat useful when shown in prompt. Not often needed, but sometimes really useful. # User-Facing Changes New key added to `gstat` output. I don't think it should cause issues to `gstat` users. # Tests + Formatting I couldn't find any tests for `nu_plugin_gstat`. # After Submitting I couldn't find any documentation about the output of `gstat`, so I don't think there is anything to be done here either.
This commit is contained in:
parent
3df0177ba5
commit
4c19242c0d
@ -133,6 +133,7 @@ impl GStat {
|
|||||||
"tag" => Value::string(tag, span),
|
"tag" => Value::string(tag, span),
|
||||||
"branch" => Value::string(stats.branch, span),
|
"branch" => Value::string(stats.branch, span),
|
||||||
"remote" => Value::string(stats.remote, span),
|
"remote" => Value::string(stats.remote, span),
|
||||||
|
"state" => Value::string(stats.state, span),
|
||||||
},
|
},
|
||||||
span,
|
span,
|
||||||
))
|
))
|
||||||
@ -160,6 +161,7 @@ impl GStat {
|
|||||||
"tag" => Value::string("no_tag", span),
|
"tag" => Value::string("no_tag", span),
|
||||||
"branch" => Value::string("no_branch", span),
|
"branch" => Value::string("no_branch", span),
|
||||||
"remote" => Value::string("no_remote", span),
|
"remote" => Value::string("no_remote", span),
|
||||||
|
"state" => Value::string("no_state", span),
|
||||||
},
|
},
|
||||||
span,
|
span,
|
||||||
)
|
)
|
||||||
@ -206,6 +208,10 @@ pub struct Stats {
|
|||||||
pub branch: String,
|
pub branch: String,
|
||||||
/// The of the upstream branch
|
/// The of the upstream branch
|
||||||
pub remote: String,
|
pub remote: String,
|
||||||
|
|
||||||
|
/// State of the repository (Clean, Merge, Rebase, etc.)
|
||||||
|
/// See all states at https://docs.rs/git2/latest/git2/enum.RepositoryState.html
|
||||||
|
pub state: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stats {
|
impl Stats {
|
||||||
@ -214,6 +220,7 @@ impl Stats {
|
|||||||
let mut st: Stats = Default::default();
|
let mut st: Stats = Default::default();
|
||||||
|
|
||||||
st.read_branch(repo);
|
st.read_branch(repo);
|
||||||
|
st.state = format!("{:?}", repo.state());
|
||||||
|
|
||||||
let mut opts = git2::StatusOptions::new();
|
let mut opts = git2::StatusOptions::new();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user