nickgerace / gfold

CLI tool to help keep track of your Git repositories, written in Rust
https://crates.io/crates/gfold
Apache License 2.0
309 stars 20 forks source link

Alphabetize output by repo name when "--display-mode=standard" #253

Closed cohml closed 6 months ago

cohml commented 9 months ago

With --display-mode=classic, the entries in the output are in alphabetical order (by path).

❯ gfold --display-mode=classic git | sed -E "s/$SENSITIVE/__/g"
/Users/__/git/__/aidy
aidy  clean  main  git@gitlab.__.org:nlplab/ACG/aidy.git

/Users/__/git/__/aws/ec2-dev-server
ec2-dev-server.add-yes-to-curfew  unclean  main  git@gitlab.__.org:nlplab/rfs/ec2-dev-server.git

/Users/__/git/__/aws/ghe-dev
ec2-dev-server-MAIN  clean  main  git@gitlab.__.org:nlplab/rfs/ec2-dev-server.git

/Users/__/git/__/cinnamon
cinnamon           unclean  LABSWS-5582-update-azure-openai-secrets  git@gitlab.__.org:plalab/ghe/oatml/cinnamon.git
cinnamon.loo_feat  unclean  LABSWS-5316-fix-long-resource-names      git@gitlab.__.org:plalab/ghe/oatml/cinnamon.git

/Users/__/git/__/pipplet_data
pipplet-data.relax-german-data  unclean  main  git@gitlab.__.org:plalab/ghe/oatml/cupboard/pipplet-data.git

/Users/__/git/__/sparkle
sparkle_engine  clean  main  git@gitlab.__.org:nlplab/rfs/engines/sparkle_engine.git

/Users/__/git/__/tartine
tartine.train_german_text_model  unclean  transformers_image  git@gitlab.__.org:plalab/ghe/oatml/cupboard/tartine.git

/Users/__/git/forks/deepdiff
deepdiff  clean  precompiled-regex-simple-diff  git@github.com:__/deepdiff.git

/Users/__/git/forks/fzf-git
fzf-git.vi-mode-keybindings  clean  feature/mode-agnostic-zsh-keybindings  git@github.com:__/fzf-git.sh.git

/Users/__/git/forks/ipython
ipython.line_numbers  unpushed  feature/add-line-numbers-to-prompt  git@github.com:__/ipython.git

/Users/__/git/forks/ipython-autotime
ipython-autotime  unclean  toggle-output-elements  git@github.com:__/ipython-autotime.git

/Users/__/git/forks/zsh-hist
zsh-hist.better-keybindings  clean  better-keybindings  git@github.com:__/zsh-hist.git

/Users/__/git/hm
dotfiles.filter_pii  clean    add-revert-script             none
nerdart              clean    fastapi                       git@github.com:__/nerdart.git
clicv                unclean  __-cv                         git@github.com:__/clicv.git
dotfiles             unclean  implement-direnv-config-file  git@github.com:__/dotfiles.git
inception            unclean  decouple-with-hub             git@github.com:__/inception.git
lc                   unclean  meta                          git@github.com:__/lc.git
nklm                 unclean  add-dev-set                   git@github.com:__/nklm.git
trapi                unclean  main                          git@github.com:__/trapi.git

[!NOTE] Many substrings have been redacted above, but trust me the paths are in alphabetical order.

But with --display-mode=standard, it seems like the order is random - neither by path nor by repo name.

❯ gfold --display-mode=standard git | sed -E "s/$SENSITIVE/__/g"
aidy ~ /Users/__/git/__/aidy/aidy
  clean (main)
  git@gitlab.__.org:nlplab/ACG/aidy.git
  __@__.org
deepdiff ~ /Users/__/git/forks/deepdiff/deepdiff
  clean (precompiled-regex-simple-diff)
  git@github.com:__/deepdiff.git
  __@__.org
dotfiles.filter_pii ~ /Users/__/git/hm/dotfiles.filter_pii
  clean (add-revert-script)
  __@__.org
ec2-dev-server-MAIN ~ /Users/__/git/__/aws/ghe-dev/ec2-dev-server-MAIN
  clean (main)
  git@gitlab.__.org:nlplab/rfs/ec2-dev-server.git
  __@__.org
fzf-git.vi-mode-keybindings ~ /Users/__/git/forks/fzf-git/fzf-git.vi-mode-keybindings
  clean (feature/mode-agnostic-zsh-keybindings)
  git@github.com:__/fzf-git.sh.git
  __@__.org
nerdart ~ /Users/__/git/hm/nerdart
  clean (fastapi)
  git@github.com:__/nerdart.git
  __@__.org
sparkle_engine ~ /Users/__/git/__/sparkle/sparkle_engine
  clean (main)
  git@gitlab.__.org:nlplab/rfs/engines/sparkle_engine.git
  __@__.org
zsh-hist.better-keybindings ~ /Users/__/git/forks/zsh-hist/zsh-hist.better-keybindings
  clean (better-keybindings)
  git@github.com:__/zsh-hist.git
  __@__.org
cinnamon ~ /Users/__/git/__/cinnamon/cinnamon
  unclean (LABSWS-5582-update-azure-openai-secrets)
  git@gitlab.__.org:plalab/ghe/oatml/cinnamon.git
  __@__.org
cinnamon.loo_feat ~ /Users/__/git/__/cinnamon/cinnamon.loo_feat
  unclean (LABSWS-5316-fix-long-resource-names)
  git@gitlab.__.org:plalab/ghe/oatml/cinnamon.git
  __@__.org
clicv ~ /Users/__/git/hm/clicv
  unclean (__-cv)
  git@github.com:__/clicv.git
  __@__.org
dotfiles ~ /Users/__/git/hm/dotfiles
  unclean (implement-direnv-config-file)
  git@github.com:__/dotfiles.git
  __@__.org
ec2-dev-server.add-yes-to-curfew ~ /Users/__/git/__/aws/ec2-dev-server/ec2-dev-server.add-yes-to-curfew
  unclean (main)
  git@gitlab.__.org:nlplab/rfs/ec2-dev-server.git
  __@__.org
inception ~ /Users/__/git/hm/inception
  unclean (decouple-with-hub)
  git@github.com:__/inception.git
  __@__.org
ipython-autotime ~ /Users/__/git/forks/ipython-autotime/ipython-autotime
  unclean (toggle-output-elements)
  git@github.com:__/ipython-autotime.git
  __@__.org
lc ~ /Users/__/git/hm/lc
  unclean (meta)
  git@github.com:__/lc.git
  __@__.org
nklm ~ /Users/__/git/hm/nklm
  unclean (add-dev-set)
  git@github.com:__/nklm.git
  __@__.org
pipplet-data.relax-german-data ~ /Users/__/git/__/pipplet_data/pipplet-data.relax-german-data
  unclean (main)
  git@gitlab.__.org:plalab/ghe/oatml/cupboard/pipplet-data.git
  __@__.org
tartine.train_german_text_model ~ /Users/__/git/__/tartine/tartine.train_german_text_model
  unclean (transformers_image)
  git@gitlab.__.org:plalab/ghe/oatml/cupboard/tartine.git
  __@__.org
trapi ~ /Users/__/git/hm/trapi
  unclean (main)
  git@github.com:__/trapi.git
  __@__.org
ipython.line_numbers ~ /Users/__/git/forks/ipython/ipython.line_numbers
  unpushed (feature/add-line-numbers-to-prompt)
  git@github.com:__/ipython.git
  __@__.org

This can make it hard to scan efficiently when there are many entries, such as in the output above.

So if standard could be alphabetical like classic (though ideally by repo name, since that is the emphasized element), it would be a nice UX improvement.

nickgerace commented 9 months ago

That's a bug! Thanks for filing an issue. They're supposed to be alphabetically sorted.

nickgerace commented 7 months ago

Okay, so this is actually expected behavior. They are sorted first by name, but then by status.

https://github.com/nickgerace/gfold/blob/3fa4afc0d385c4a5e2262364c6cee06ac21cc339/bin/gfold/src/display.rs#L55-L56

However, I'm contemplated whether or not this is good default behavior. I could totally see why users would expect it to be in raw alphabetical order. I believe the solution is to add a new display mode (e.g. standard-alphabetical) that keeps backwards compatibility in mind.

cohml commented 7 months ago

Thanks for investigating. I agree that both display modes could be useful in certain scenarios. +1 for making it configurable.

nickgerace commented 6 months ago

Available with version 4.5.0