// Get the short status (ahead, behind, and modified files) of a repo
Get the short status (ahead, behind, and modified files) of a repo
Get the short status ( ahead behind and modified files ) of a repo
pub fn stat(p: &Path) -> Result<Option<String>> {
    let out_lines = command_output(p, &["status", "-s", "-b"])?;
    if out_lines.is_empty() {
        Ok(None)
    } else if out_lines[0].ends_with(']') {
        // We have an 'ahead', 'behind' or similar, so free to return the status early
        Ok(Some(format!("{}\n{}\n", p.display(), out_lines.join("\n"))))
    } else {
        // We aren't ahead or behind etc, but may have local uncommitted changes
        let status: Vec<String> = out_lines
            .par_iter()
            .skip(1)
            .map(|x| x.to_string())
            .collect();
        if status.is_empty() {
            Ok(None)
        } else {
            Ok(Some(format!("{}\n{}\n", p.display(), status.join("\n"))))
        }
    }
}
pub fn stat ( p : & Path ) -> Result < Option < String > > { let out_lines = command_output ( p , & [ " " , " " , " " ] ) ? ; if out_lines . is_empty ( ) { Ok ( None ) } else if out_lines [ 0 ] . ends_with ( ']' ) { // We have an 'ahead', 'behind' or similar, so free to return the status early Ok ( Some ( format ! ( " \n \n " p display ( ) out_lines join ( " \n " ) ) ) ) } else { // We aren't ahead or behind etc, but may have local uncommitted changes let status : Vec < String > = out_lines . par_iter ( ) . skip ( 1 ) . map ( | x | x . to_string ( ) ) . collect ( ) ; if status . is_empty ( ) { Ok ( None ) } else { Ok ( Some ( format ! ( " \n \n " p display ( ) status join ( " \n " ) ) ) ) } } }
Get the short status (ahead, behind, and modified files) of a repo
Get the short status ( ahead behind and modified files ) of a repo
p
&Path