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

Create a git integration #7

Closed
Peltoche opened this issue Dec 4, 2018 · 31 comments
Closed

Create a git integration #7

Peltoche opened this issue Dec 4, 2018 · 31 comments
Labels
kind/enhancement Enhancement on current feature

Comments

@Peltoche
Copy link
Collaborator

Peltoche commented Dec 4, 2018

No description provided.

@Peltoche Peltoche added the kind/enhancement Enhancement on current feature label Dec 5, 2018
@alichtman
Copy link
Contributor

Can you explain what kind of git integration you're looking to add?

@Peltoche
Copy link
Collaborator Author

Peltoche commented Dec 7, 2018

Hello @alichtman,

There is no defined specs yet. This feature is already implemented by the colorls and the exa projects, I think it can be a good start to check how they do it.

@ysf
Copy link

ysf commented Dec 11, 2018

There is an example on the exa website: https://the.exa.website/features/git

Basically there is a new column that displays the git status for the files in the listed directory. (new, modified etc..)

@Peltoche
Copy link
Collaborator Author

Seems cool. I think that we can do something even better with the icons support. I don't know if we should add a new icons for the git status or just override the existing one. We can also add a new column of course.

@cjbassi
Copy link

cjbassi commented Feb 23, 2019

Another tool to check out that displays the git status of files is ranger. I like their use of icons, and I also like that they display the git status of entire repos too, so you could ls -l the current directory and see which repos are dirty. Screenshot.

@leomikezee
Copy link

Maybe add a option or a flag to hide files based on the .gitignore file

@patevs
Copy link

patevs commented Apr 20, 2020

I definitely support this. Would be useful to be able to see the current git status of files and also being able to hide files based on the .gitignore file.

@aseifert
Copy link

+1 from me! I'd really love to have this as well, it's the only thing I still miss from exa/colorls!

@sherifabdlnaby
Copy link

+1!!!!

@hpwxf
Copy link
Contributor

hpwxf commented Feb 28, 2021

I like this idea; maybe I can do it. Is there already someone on this issue ?

About the icons, if we want funny glyphs, my suggestions are (from https://www.nerdfonts.com/cheat-sheet)
* check (-): nf-fa-check f00c
* modified (M): nf-fa-gear f013
* uknown (?): nf-fa-user_secret f21b
* ignored (!) : nf-mdi-ghost f79f (or nf-fa-exclamation f12a)
* new (+) : nf-mdi-login_variant fafb
Capture d’écran 2021-02-28 à 13 11 49

The display should be with two columns (staged, not staged)

To get git info, I can use libgit2 (https://github.com/rust-lang/git2-rs)

Is there any other constraint ?

@zwpaper
Copy link
Member

zwpaper commented Mar 1, 2021

Hi @hpwxf , There is noone working on this right now, please feel free to take this up and thanks for contributing to LSD!

as the icons part, maybe we should have @meain 's attention,
for my personal opinion, it is cute! XD

PS:
I was thinking to work on a configuration file for the icons after the theme one, so do not let the glyphs stop your progress

@meain
Copy link
Member

meain commented Mar 1, 2021

Hey @hpwxf, thanks a lot for taking looking into this. I have not been able to fully think through it but here are few things that I wanted to mention.

I don't think separating the output of ls to two columns would be a good idea, this should be just a "block" similar to size or date. As for the representation, we could use how git-status represents it with two items (working tree and index). This would make the data familiar to read. We kinda loose the details on partially staged files for example if we stick to just one char/icon.

About the icons, I think icons should be optional as this feature should also be usable by people who do not have the proper fonts setup. We could have this configurable and make it use icons, but I am not also worried if having two icons close together would look good.

Related to the implementation, when listing a top level folder lsd should be able to notify even if there is some change in some file that is under a specific folder.

hpwxf added a commit to hpwxf/lsd that referenced this issue Mar 1, 2021
Gather flags for all files in a git directory (panic out of git directory).
@hpwxf
Copy link
Contributor

hpwxf commented Mar 2, 2021

To define a status for a directory, I suggest to use a kind of max on the status of the files inside.
I use this order:

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum GitStatus {
    /// No changes
    Unmodified,
    /// Entry is ignored item in workdir
    Ignored,
    /// Entry does not exist in old version
    New,
    /// Type of entry changed between old and new
    Typechange,
    /// Entry does not exist in new version
    Deleted,
    /// Entry was renamed between old and new
    Renamed,
    /// Entry content changed between old and new
    Modified,
    /// Entry in the index is conflicted
    Conflicted,
}

it means that a conflict will always be shown whatever the other modifications; if no conflict, the second most important status is Modified...

Below, a output example (fancy icons will come later). For this example, in the previous commit, each sub/directory contained two files file1 and file2.
Snapshot

Is it what you expect ?

@meain
Copy link
Member

meain commented Mar 4, 2021

@hpwxf That sounds good.

hpwxf added a commit to hpwxf/lsd that referenced this issue Mar 7, 2021
* Enabled using `cargo build --feature=git`
* git block is by default on the left of name block
* use `lsd --git --long` to enable git status info (only available on long display)
* sort by git status using `lsd --sort=git --long`
hpwxf added a commit to hpwxf/lsd that referenced this issue Mar 7, 2021
* Enabled using `cargo build --feature=git`
* git block is by default on the left of name block
* use `lsd --git --long` to enable git status info (only available on long display)
* sort by git status using `lsd --sort=git --long`
@hpwxf hpwxf mentioned this issue Mar 7, 2021
3 tasks
hpwxf added a commit to hpwxf/lsd that referenced this issue Mar 23, 2021
* Enabled using `cargo build --feature=git`
* git block is by default on the left of name block
* use `lsd --git --long` to enable git status info (only available on long display)
* sort by git status using `lsd --sort=git --long`
hpwxf added a commit to hpwxf/lsd that referenced this issue Apr 3, 2021
* Enabled using `cargo build --feature=git`
* git block is by default on the left of name block
* use `lsd --git --long` to enable git status info (only available on long display)
* sort by git status using `lsd --sort=git --long`
@typkrft
Copy link

typkrft commented Aug 9, 2021

Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.

@hpwxf
Copy link
Contributor

hpwxf commented Aug 11, 2021

Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.

After this PR is merged, this seems to be a doable improvement.

@sherifabdlnaby
Copy link

I love lsd, I prefer it over exa but I miss the Git Integration, why has this feature not been considered yet?

@hpwxf
Copy link
Contributor

hpwxf commented Sep 11, 2022

For sure, PR #495 should be updated.

Is there only this remark #495 (comment) to solve?

@LucaAngioloni
Copy link

Any news on this?

@hpwxf
Copy link
Contributor

hpwxf commented Feb 12, 2023

Thank you to ask. It seems useful to update my PR. I will try to do on next Wednesday (Feb 15th).
I hope the code hasn't changed too much since my first version.

@meain
Copy link
Member

meain commented Feb 15, 2023

@hpwxf Thanks for the interest. I unfortunately don't have much time these days to look into major features in lsd. I'm fine if @zwpaper can take up review of this one. Just wanted to give you a heads up so as to not waste your time.

@zwpaper
Copy link
Member

zwpaper commented Feb 16, 2023

Hi @meain @hpwxf, I also do not have much time for this significant feature, but luckily we have already done most of the work previously, let's keep going and I will try my best to make it happen.

@hpwxf
Copy link
Contributor

hpwxf commented Feb 19, 2023

I'm rebasing my previous work on master branch. --git option seems to work again.

I have many #[cfg(feature = "git")] to support git as an optional feature.

What do you prefer? default feature or optional feature ?

@meain
Copy link
Member

meain commented Feb 19, 2023

I'm thinking it could be enabled on systems that support it. Don't think there is any point in keeping it optional.

@hpwxf
Copy link
Contributor

hpwxf commented Feb 19, 2023

Ok; the only unsupported arches are:

  • arm-unknown-linux-gnueabihf (now supported by removing non necessary features from git2-rs)
  • i686-pc-windows-gnu

Before the PR, I've just something to check about

and it should be done (hopefully in a few days).

@hpwxf
Copy link
Contributor

hpwxf commented Feb 26, 2023

It's almost done. To fix issues shown in my previous PR, I need to know how to manage the case where we have:

  1. a sub-directory 'subdir' that uses git (but not the current one): show or not a git status for subdir?
  2. a sub-directory that uses git and the current one also uses git + option --tree: show git status related to current dir or a status as if we use git status inside each subdirectory?

In other words, do you consider that the output of exa -l --git [--tree] is what we want?

Here my demo to plau this
demo.zip

And some comparisons on it between exa and my proposal.

Case 1.:
exa-1
lsd-1

Case 2.:
exa-2

lsd-2

@zwpaper
Copy link
Member

zwpaper commented Feb 28, 2023

hi @hpwxf, in my opinion, I would vote +1 for the exa output, as git status also output like this.

@hpwxf
Copy link
Contributor

hpwxf commented Mar 3, 2023

I'm waiting two days for any other suggestions, and then I push my PR.

@hpwxf hpwxf mentioned this issue Mar 11, 2023
5 tasks
@zwpaper
Copy link
Member

zwpaper commented May 25, 2023

/close

1 similar comment
@zwpaper
Copy link
Member

zwpaper commented May 25, 2023

/close

@muniu-bot muniu-bot bot closed this as completed May 25, 2023
@muniu-bot
Copy link

muniu-bot bot commented May 25, 2023

@zwpaper: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancement on current feature
Projects
None yet
Development

No branches or pull requests