tarantool / docbot

Bot to automate some GitHub things
4 stars 1 forks source link

Provide four-digit version number #6

Open Totktonada opened 4 years ago

Totktonada commented 4 years ago

I propose to give git describe --long <commit> output as part of a filed issue.

The relevant code:

https://github.com/tarantool/docbot/blob/1211606da71b4dae7c59b97e79ac821a7979446c/tarantoolbot.py#L115-L116

I would change it like so when:

description = '{}\nRequested by @{} in [{}]({}).'.format(
    description, author, git_describe, src_url)

It should be useful for https://github.com/tarantool/doc/issues/1415

Details

Manage repository mirror

It seems we need to maintain a bare repository (clone if it not exists and update on demand) and use a command like git --git-dir <mirror-dir> describe --long <commit>.

I would fallback to the just commit without git describe --long <commit> if something going wrong with the mirror or if a commit is not found.

Commenting issue flow

It would be easier to implement the feature for the flow when a documentation comment is placed within a commit: we already know a commit hash.

However it is possible too for comments placed within an issue using issue events:

$ curl -fsS 'https://api.github.com/repos/tarantool/tarantool/issues/5223/events?page=1' | \
  jq --raw-output '.[] | select(.event=="closed") | .commit_id'
29ec628918bd7279de08e47becc070420775c2eb

I would traverse over a constant number of pages to find a "closed" event and fallback to just commit without git describe --long <commit> if such event is not found or if commit_id is null.

NB: It is not possible to directly fetch such event, because its event_id is not the same number as id field within a webhook event.