mirror of
https://github.com/nushell/nushell
synced 2025-01-09 03:39:03 +00:00
b2c5af457e
This improves incremental build time when working on what was previously the root package. For example, previously all plugins would be rebuilt with a change to `src/commands/classified/external.rs`, but now only `nu-cli` will have to be rebuilt (and anything that depends on it).
21 lines
570 B
Rust
21 lines
570 B
Rust
#![cfg(not(feature = "starship-prompt"))]
|
|
|
|
use git2::{Repository, RepositoryOpenFlags};
|
|
use std::ffi::OsString;
|
|
|
|
pub fn current_branch() -> Option<String> {
|
|
let v: Vec<OsString> = vec![];
|
|
match Repository::open_ext(".", RepositoryOpenFlags::empty(), v) {
|
|
Ok(repo) => {
|
|
let r = repo.head();
|
|
match r {
|
|
Ok(r) => match r.shorthand() {
|
|
Some(s) => Some(s.to_string()),
|
|
None => None,
|
|
},
|
|
_ => None,
|
|
}
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|