Skip to content

Commit

Permalink
feat(commit): display git statuses and error message on commit to emp…
Browse files Browse the repository at this point in the history
…ty index
  • Loading branch information
oknozor committed Sep 24, 2020
1 parent 88d67a0 commit 2f37106
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,25 @@ impl Repository {
.map_err(|err| anyhow!(err))
} else {
let statuses = self.get_statuses()?;
statuses.iter().for_each(|status| {
eprintln!("{} : {:?}", status.path().unwrap(), status.status());
statuses.iter().for_each(|entry| {
let status = match entry.status() {
s if s.contains(git2::Status::WT_NEW) => "Untracked: ",
s if s.contains(git2::Status::WT_RENAMED) => "Renamed: ",
s if s.contains(git2::Status::WT_DELETED) => "Deleted: ",
s if s.contains(git2::Status::WT_TYPECHANGE) => "Typechange: ",
s if s.contains(git2::Status::WT_MODIFIED) => "Modified: ",
s if s.contains(git2::Status::INDEX_NEW) => "New file: ",
s if s.contains(git2::Status::INDEX_MODIFIED) => "Modified: ",
s if s.contains(git2::Status::INDEX_DELETED) => "Deleted: ",
s if s.contains(git2::Status::INDEX_RENAMED) => "Renamed: ",
s if s.contains(git2::Status::INDEX_TYPECHANGE) => "Typechange:",
_ => "unknown git status",
};
println!("{} {}", status.red(), entry.path().unwrap());
});
println!();

// TODO
Err(anyhow!("{} : {} ", is_empty, has_delta))
Err(anyhow!("nothing to commit (use \"git add\" to track)"))
}
}

Expand Down

0 comments on commit 2f37106

Please sign in to comment.