app-gitgot icon indicating copy to clipboard operation
app-gitgot copied to clipboard

`got ls` should do substring match if given arg that isn't exact repo name

Open genehack opened this issue 12 years ago • 2 comments

got ls would be more useful if it was a bit smarter.

Given a configuration containing three repos:

  • foobar
  • foobaz
  • foobarbaz

currently, got ls foo displays nothing. That seems wrong. Clearly, it should instead list all three repos. Similarly, got ls bar should list the first and the third repos in the above list.

The question is, what should got ls foobar display? Should it only display the first, because it is an exact match? Or should it display the first and the third, since the third is a substring match as well?

The disadvantage of the former approach is that it might be confusing in some cases (consider, for example, the output of got ls fooba versus got ls foobar). The disadvantage of the latter approach is that it would make got ls work differently than other subcommands that take repo names.

This could maybe be resolved via the use of an argument (or even a configuration option) detailing whether to do substring matching always, never, or only when requested.

genehack avatar Apr 15 '13 13:04 genehack

I have just set up the got command to manage my repositories and one of the first things I missed was a more powerful way to select repositories. Tags are nice, but regexen or even plain glob patterns would be nicer still.

What do you think of consider non-numeric arguments as glob patterns matching repos by name, case insensitivelly? I mean, you could use Text::Glob to build regexes from the arguments and match them against the list of repos.

With your examples this would mean that:

  • got ls foo would match nothing
  • got ls foo* would match all three

This seems easy and intuitive, keeping it even backwards compatible with the current version, no?

Sometimes glob patterns can be a little constraining. How about treating strings between slashes are proper regexen? Like got ls /baz$/ to match foobaz and foobarabz?

Is it too forced?

gnustavo avatar Jan 07 '15 00:01 gnustavo

My initial reaction is you'd have to quote the repo names to make sure the shell didn't grab the glob (i.e., your example would need to be got ls 'foo*' to be safe).

My subsequent reaction is, I need to think about this more. 8^) Leaving ticket open.

genehack avatar Feb 24 '15 02:02 genehack