diff options
author | John Breen <john@breen.tech> | 2021-05-07 19:31:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 19:31:18 -0400 |
commit | 45bb13047d7a0b68a2ddb5776b9140270312b6a0 (patch) | |
tree | ea6a166f73f9c23982115ffd54170e9c0179067b /src | |
parent | c4f977c48d29790f27d332c32d97eff40fd258f1 (diff) |
fix(git_status): Show git add -N files as unstaged (#2702)
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/git_status.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index eaacbb5ec..b8dd655ad 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -256,7 +256,7 @@ impl RepoStatus { fn is_modified(status: &str) -> bool { // is_wt_modified - status.starts_with("1 .M") + status.starts_with("1 .M") || status.starts_with("1 .A") } fn is_staged(status: &str) -> bool { @@ -634,6 +634,21 @@ mod tests { } #[test] + fn shows_added() -> io::Result<()> { + let repo_dir = fixture_repo(FixtureProvider::Git)?; + + create_added(&repo_dir.path())?; + + let actual = ModuleRenderer::new("git_status") + .path(&repo_dir.path()) + .collect(); + let expected = format_output("!"); + + assert_eq!(expected, actual); + repo_dir.close() + } + + #[test] fn shows_staged_file() -> io::Result<()> { let repo_dir = fixture_repo(FixtureProvider::Git)?; @@ -870,6 +885,18 @@ mod tests { Ok(()) } + fn create_added(repo_dir: &Path) -> io::Result<()> { + File::create(repo_dir.join("license"))?.sync_all()?; + + Command::new("git") + .args(&["add", "-A", "-N"]) + .current_dir(repo_dir) + .output()?; + barrier(); + + Ok(()) + } + fn create_modified(repo_dir: &Path) -> io::Result<()> { File::create(repo_dir.join("readme.md"))?.sync_all()?; |