Search by arbitrary metadata

Timeline

Miklos Vajna (vmiklos) opened

In case a bug is imported (e.g. from github), then git-bug knows that url, e.g.:

$ git show refs/bugs/016b3f0c56c1724c0230919ce3218b5cfa19f8ce:root|python3 -m json.tool
{
    "version": 2,
    "ops": [
        {
            "type": 1,
            "author": {
                "id": "e256bc3329691afb0ed3f7d3b9675ef8cecd1a16"
            },
            "timestamp": 1583555863,
            "metadata": {
                "github-id": "MDU6SXNzdWU1NzcyNzY4MTY=",
                "github-url": "https://github.com/author/myproject/issues/6",
                "origin": "github"
            },

It would be nice if e.g. git bug ls could search in this metadata. So let's say I'm offline and I would like to look up https://github.com/author/myproject/issues/6, then that would be possible. Perhaps something like:

git bug ls --metadata github-url=https://github.com/author/myproject/issues/6

could list all matching bugs, typically just one.

Miklos Vajna (vmiklos) commented

@MichaelMure what do you think? I don't mind taking a look at this myself, just wanted to do a sanity-check on the idea in general and on the syntax in particular before I invest time in coding this. Thanks.

Michael Muré (MichaelMure) commented

I guess that make sense. The syntax is a bit problematic though (both for the query language and the CLI argument for ls): you need to specify both key and value, which is something both of them don't do yet.

To be able to search like that you would need to:

  1. add the metadata in the index (see BugExcerpt) actually it's already there, CreateMetadata in BugExcerpt
  2. add a new keyword in the query language (/query), find a way to deal with the key/value problem
  3. implement the search (/cache/filter.go)
  4. connect all that stuff in the ls command, deal with the key/value problem

Michael Muré (MichaelMure) changed the title from Search by arbitrary metadata to Search by arbitrary metadata

Miklos Vajna (vmiklos) commented

Thanks! I have a PoC (without any error handling) based on the above, will submit a PR when I don't see obvious problems with it anymore.

Michael Muré (MichaelMure) commented

You can also open a draft PR for some early feedback (if I find the time of course), as you prefer.

Michael Muré (MichaelMure) closed the bug