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

[#16] Colour staged files #35

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

LeedsJohn
Copy link
Contributor

Hi - this PR addresses issue 16 - Colour staged files in 'zbg status'.

I created a function to get a list of staged files using git diff --name-only --cached [commit]. This is used so that I could get a list of staged files before calling with_deleted_files and with_untracked_files (which temporarily stage deleted and untracked files). Then, we can pass the list of staged files along to fmt_diff_stats so we know which files we want to change to be green and bold.

There is still a loss of information in this implementation compared to calling git status - if a file is staged and then modified again, zbg status will now highlight the name green but git status would list the file as both staged and modified. Do you have any thoughts about this discrepancy?

Here's an example of the current behavior:

image

Let me know what changes you would like for me to make - I'm happy to rewrite if you think this problem should be solved differently. Thanks!

Copy link
Owner

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the implementation! Really neat 🚀

There is still a loss of information in this implementation compared to calling git status - if a file is staged and then modified again, zbg status will now highlight the name green but git status would list the file as both staged and modified. Do you have any thoughts about this discrepancy?

I'm fine with this loss 👍🏻

I rarely want to edit a file, stage it, modify it again and commit only the staged part. So I'm fine with displaying it as staged

@chshersh chshersh merged commit 9fa381b into chshersh:main Jan 4, 2024
4 checks passed
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.

None yet

2 participants