Skip to content

proposal: /commands (set-more-info-link in particular) #12

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

Open
bl-ue opened this issue Apr 19, 2021 · 5 comments
Open

proposal: /commands (set-more-info-link in particular) #12

bl-ue opened this issue Apr 19, 2021 · 5 comments

Comments

@bl-ue
Copy link

bl-ue commented Apr 19, 2021

I recently wrote a Python script, set-more-info-link.py (tldr-pages/tldr#5654) that takes a page in the format platform/page.md and a link, and adds/updates the link in the page and all translations using a map of the approprate labels.

I was thinking just now that it might be nice to be able to, in a PR, comment something like

@tldr-bot /set-more-info-link common/page.md "https://example.com"

whereupon the bot (@tldr-bot) ran set-more-info-link.py with those arguments, committed the changes to the PR, maybe the message could be like

page: update more information link

If this were approved, I'd be happy to work on it.

@sbrl
Copy link
Member

sbrl commented Apr 19, 2021

That's a nice idea! Could be convenient.

Security must be central to the implementation though. @tldr-bot should check to make sure that the user executing the command actually permission to do so on that particular PR.

How does it handle these cases?

  • Pages in other languages
  • Pages that already have a more information link
  • Pages with invalid syntax (i.e. invalid syntax that tldr-bot has previously commented on

@bl-ue
Copy link
Author

bl-ue commented Apr 19, 2021

@tldr-bot should check to make sure that the user executing the command actually permission to do so on that particular PR.

Definitely. Would be very simple to ensure.

  • Pages in other languages.

The script applies the appropriate label for the language the page is in. See here

  • Pages that already have a more information link

The script overwrites the existing link in the pages that already have one, and adds it to pages that don't.

  • Pages with invalid syntax (i.e. invalid syntax that tldr-bot has previously commented on

I'm not sure how the script would react to that. It finds were to insert/modify the line by checking for > at the beginning; in most cases it would probably be fine. We could also perhaps check if there is a comment (maybe non-hidden?) by @tldr-bot and if there are any commits after it, run the script, otherwise stop.

@bl-ue
Copy link
Author

bl-ue commented Apr 19, 2021

@sbrl keep in mind that we already have a script that does this (tldr-pages/tldr#5654), but the issue with it that I see is that it's somewhat cumbersome to use, and contributors need Python installed, and it would be really inconvenient to have to install Python just to change some links.

@sbrl
Copy link
Member

sbrl commented Apr 19, 2021

Cool, that sounds sensible - just wanted to check some edge cases there. I can definitely see the appeal of adding this to the tldr-bot. I would suggest a check that if the GitHub actions have failed on the target PR, then it does not attempt to make a change. If the GitHub actions are in progress, it reschedules the check for say 5 minutes time, but that might be complex to program.

@sebastiaanspeck
Copy link
Member

Is this enhancement still valid? I believe everyone runs the script locally. I don't think it would be a good idea to use this script via the bot. Especially since it's all or nothing at the moment. You can't specify "update the link for page common/X" (is also not possible for the other scripts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants