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

Limit gita ll column widths #264

Closed
elcorto opened this issue Oct 16, 2023 · 6 comments · Fixed by #278
Closed

Limit gita ll column widths #264

elcorto opened this issue Oct 16, 2023 · 6 comments · Fixed by #278

Comments

@elcorto
Copy link
Contributor

elcorto commented Oct 16, 2023

Hi

Thanks for this project.

I have a question related to column widths in the gita ll output, using the current master (a5ba6fe).

  • long repo names shift the output rather far to the right
  • long branch names disturb the branch name + status column
very_very_very_very_long_repo_name_why_not     main     []    Commit mesage here (4 weeks ago)
a_repo                                         long-branch-name-here [] Commit mesage here (4 weeks ago)
another_repo                                   master   []    Commit mesage here, and some more long long text (4 weeks ago)

Is there a way to configure a max width per column?

I have an experimental branch based off a rather old master. There I just hard-coded some width quickly. I had to rewrite some code to separate the branch name and the branch state in order to apply the string length truncation only to the branch name. Not sure if this is still the case in the current code. I used tabulate to help with the column printing, which looks like this:

repo                              head                     state    commit_msg                        commit_time
--------------------------------  -----------------------  -------  --------------------------------  -----------------------
very_very_very_very_long_repo_..  main                              Commit mesage here                (4 weeks ago)
a_repo                            long-branch-name-here             Commit mesage here                (4 weeks ago)
another_repo                      main                              Commit mesage here, and some m..  (4 weeks ago)

Separating branch name and state made it also possible to support a -d/--dirty flag. Not sure if there is an equivalent feature in master. I also tried to use rich for table layout but that didn't work that well, probably because of the color escape codes, but that's just a guess. Anyway that branch is rather different from current master by now and lacks nice features such as concurrent execution. Since it is difficult to rebase that branch onto current master, I was wondering if there is a way to truncate the column widths in the current code. Thanks a lot!

@nosarthur
Copy link
Owner

maybe the easy solution is to add an option for gita ll to limit the lengths for all columns

btw, one can also change repo name with gita rename .... Gita treats the repo name and the repo path separately

@elcorto
Copy link
Contributor Author

elcorto commented Oct 19, 2023

maybe the easy solution is to add an option for gita ll to limit the lengths for all columns

Yes a command line flag or a config option would be nice. As mentioned I don't know how easy it would be to support this if branch name + status are treated as one string, which was the case when I last checked. But looking at the current master, this seems to be separated now?

btw, one can also change repo name with gita rename .... Gita treats the repo name and the repo path separately

What does this do? The help text "rename the chosen repo" doesn't go into details. I guess it changes the name in the second column of ~/.config/gita/repos.csv?

In both cases, having the names truncated of course assumes that the part of the name that is displayed is still unique and informative, but I guess here a configurable length will cover most use cases. Renaming (setting an alias?) with gita may be a workaround, but only for repo names. Also in the repo case, one could probably rename the repo itself if a shorter name was possible.

@nosarthur
Copy link
Owner

please try 0.16.7.2

@elcorto
Copy link
Contributor Author

elcorto commented Jun 30, 2024

Thanks a lot!

I tested this feature and would like to give some feedback.

$ gita info
In use: branch,commit_msg,commit_time
Unused: branch_name,path

$ cat ~/.config/gita/layout.csv
branch,symbols,branch_name,commit_msg,commit_time,path
19,5,27,0,0,30

gita info says I'm not using branch_name and path. I could not figure out what the difference between branch and branch_name is. Are those "information items" (from gita info -h) documented somewhere?

With the above settings, I get

$ gita ll
very_very_very_very_long_repo_name_why_not     main                    [] Commit mesage here (4 weeks ago)
a_repo                                         long-branch-name-h...   [] Commit mesage here (4 weeks ago)
another_repo                                   master                  [] Commit mesage here, and some more long long text (4 weeks ago)

The branch width seems to affect the branch name (2nd column), which is great. However, I found no way to truncate the repo name (first column). The only setting that sounds like this is path but according to gita info I'm not using this. Thanks.

@nosarthur
Copy link
Owner

Repo name is not an info item since it has to be displayed. It is out of the truncator mechanism currently

https://github.com/nosarthur/gita/blob/master/gita/utils.py#L419

@elcorto
Copy link
Contributor Author

elcorto commented Jul 4, 2024

OK I see, thanks a lot.

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 a pull request may close this issue.

2 participants