Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes line #166

Merged
merged 7 commits into from
Nov 18, 2019
Merged

Add changes line #166

merged 7 commits into from
Nov 18, 2019

Conversation

axdiamond
Copy link
Contributor

This addresses #165

Onefetch will now show a changes line when there are uncommitted changes in the repo!

Basically, it takes the output of git diff --shortstat HEAD, and replace the text with appropriate symbols.

files changed into +-
insertions(+) into +
deletions(-) into -

@o2sh
Copy link
Owner

o2sh commented Nov 17, 2019

Thanks a lot for your contribution @axdiamond

Few remarks:

  • I think it would be better to call it Pending instead of Changes, to let the user know that this are only uncommited changes + it prevents having to treat singular/plural cases --> Change(s)
  • About the positioning, maybe place it just below HEAD
  • You are mixing information at line level (insertion(s)(+), deletion(s)(-)) with information at file level (file(s) changed), maybe git diff ---shortstat is not the right command for the job...We only want file level infos for now, git status shows it pretty well.

Looking forward to merge your PR 👍

@axdiamond
Copy link
Contributor Author

@o2sh I did the other changes, but I'm not sure how to get lines changed from git.

git status only shows files modified, not lines.

Do you have any suggestions on how I should get the lines changed?

@o2sh
Copy link
Owner

o2sh commented Nov 17, 2019

git status only shows files modified, not lines.

That's right, we are only interested in file level changes.

@axdiamond
Copy link
Contributor Author

Ooooohhh I'm a silly goose.

How does it look now?

@axdiamond
Copy link
Contributor Author

I'm new to rust btw, so any nitpicking is welcome!

@o2sh
Copy link
Owner

o2sh commented Nov 18, 2019

I detected one missing checks --> "A" | "AM" |"??" => added += 1, (AM)


if one of these

let mut deleted = 0;
let mut added = 0;
let mut modified = 0;

remains equal to zero, it shouldn't be shown in the result.


I'm new to rust btw, so any nitpicking is welcome!

LGTM, @spenserblack did I miss smth?

@o2sh
Copy link
Owner

o2sh commented Nov 18, 2019

if (modified == 0 || modified && added == 0) , you get a leading whitespace --> I'll trim the result.


Thanks a lot for your help @axdiamond , your contribution was very much appreciated 🥇

@o2sh o2sh merged commit 28cab16 into o2sh:master Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants