probot / ideas

Share ideas for new GitHub Apps built with Probot
96 stars 48 forks source link

🔎 Find-Replace-Bot: let bot submit typo-fixing PR for you! #56

Open choznerol opened 6 years ago

choznerol commented 6 years ago

What to solve?

Countless static HTML sites are hosted on GitHub, and sometimes front-end developers like me have to take so many steps just to update a minor change to plain text! This tool aims to achieve two goals:

  1. Provide developers a fast and easy way to do minor updates of plain text. It should be fast and easy enough that we would love to do it on a mobile phone.
  2. Provide non-developer team member a super easy way to update plain text themselves. They only need to open an issue, or even just type it in a slack channel (feature #8).

How it works?

The idea is simple: When an issue contains /replace 'foo' with 'bar' is created, the bot will go look for all foo in the repo and starts a PR to replace it. The workflow would be like:

mock workflow
STEP 1: Open an issue with the keyword /replace
screen shot 2018-03-18 at 3 52 49 pm
STEP 2: Review and press the merge button
screen shot 2018-03-18 at 3 54 42 pm pr file change

Expect features

feature # description
1 Replace pattern for specific filee.g. /replace '<pattern>' with '<replacement>' in '<filename>'
2 Replace all occurrences if in '<filename>' is not provided. e.g. /replace '<pattern>' with '<replacement>'
3 Configurable via find-replace-bot.yml in the project root
4 Assign generated PR to OP
5 Can specify assignee of generated PR  with the syntax:/replace 'foo' with 'bar' assign 'john_doe'
6 Can specify targeted branch with the syntax: /replace 'foo' with 'bar' in 'develop' p.s. need to distinguish between file name and branch name for the in keyword
7 Can identify regex pattern
8 Slack integration to let non-developer triggers text update PR directly from the channel
9 Raise warning message for patterns like code rather than plain text  (thread)(configurable in find-replace-bot.yml)
10 Optionally skip pre-push hooks, if CI is detected (need to find out technical feasibility)(configurable in find-replace-bot.yml)
more (Please share your thought!)
anshumanv commented 6 years ago

I totally like the idea :+1: :smile:

choznerol commented 6 years ago

Thanks @anshumanv :D

Hi @gr2m I plan to apply for GSoC 2018 with this as the proposal, I would be appreciated to know what you and the team think about it :)

gr2m commented 6 years ago

Hey have you seen https://github.com/marmelab/sedy, looks similar to what you want to build?

choznerol commented 6 years ago

I thought someone may have the similar idea but didn't found sedy! @gr2m thanks for the information 👍 but since it requires a pull request to be open in the first place ((#62), perhaps a bot response to issues suits other scenarios. Is it a good direction for a GSoC proposal?

gr2m commented 6 years ago

sure we are curious to see what you come up with :)

IAmHughes commented 6 years ago

Personally I don't know how great this would be in real-world. I've definitely come across the issue you are trying to solve as a developer, but it would also scare me to NO END 😨to have something like that done with a fairly simple find/replace, rather than a refactor-based replace within an IDE (for example).

When you refactor => rename for example, it checks instances in a much more intelligent way than a find all => replace all instances fashion.

I think this would be a great bot for someone to build, shouldn't take too much time, but I'm struggling a bit with the feasibility and use case in a real world shop. Have you come across times that the refactor => rename-like tool(s) didn't solve what you need? I know the ease of opening an issue instead of an IDE can be a plus, but other than that I don't see too much difference in time saving versus risk.

I'd love to hear your thoughts!

choznerol commented 6 years ago

@IAmHughes Thanks for the feedback!! But first sorry I used refactor in a misleading way. What I imagined was just a non-developer-friendly way of changing plain text (for rewording purpose). For example, there are many simple static HTML site hosted on GitHub and many front-end developers (including me lol) spend so much time updating plain text or typo. So I try to find an even easier way than using the ✎ button.

What you mentioned would definitely worth concern. We don't want to see this tool used to produce PRs with lousy code. My first thought is configurable warnings for /replace "something like code" with "something like code" For example:

👱: (open new issue) /replace 'userNames' with 'userName'
🤖: Sorry @OriginalPoster, this looks like refactoring rather than typo fixing to me. If you insist, please retry with a `--force` flag.

And maybe in some config file we can have customizable regex patterns to trigger warn/reject:

// find-replace-bot.yml
warning:
  message: This pattern looks like refactoring rather than typo fixing ...
  patterns:
    - <regex for camelCase>
    - <regex for CONSTANT>
reject:
  message: Please only use `/replace` for updating text-like content.
  patterns:
    - <regex for code-like stuff>

Would love to hear your thoughts! (perhaps a full-feature refactor is more attractive?)

IAmHughes commented 6 years ago

I see what you mean now, and I know we definitely use GitHub repos for documentation even (as in with no code at all in a repo), so the find & replace style would be great for those types of things. I'll have to put some thought on this as well, I like the idea!

Perhaps you can just specify the file name in the issue?

/replace 'usernames' with 'userName' in 'file.txt'

choznerol commented 6 years ago

@IAmHughes Thanks this sound like a great idea! For most typo fixing, targeting specific file is probably more useful then replacing all occurrences.

This also reminds me of some other features like: /replace 'foo' with 'bar' assign 'john_doe' // assign the generated PR to @john_doe /replace 'foo' with 'bar' for 'develop' // open branch from develop and sand PR back to it

I'll also try to come up with more configurable behavior, together with a draft config file, and update them here, please let me know if you know some more ideas :D

choznerol commented 6 years ago

I've updated the discussed features to above issue body and put the draft configuration file in the README of new repo @IAmHughes fyi :)

Berkmann18 commented 6 years ago

This sounds great, is there any plans on making that bot refactor stuff like renaming variable names, ...?

PatMyron commented 5 years ago

Pulling many dictionaries could automate typo PRs without flagging technical terms like AWS, EC2, S3, etc. Nice to allow users to configure their own dictionaries to add organization-specific words to ignore.

Berkmann18 commented 5 years ago

@PatMyron But surely that wouldn't be necessary in the case where people are manually triggering the bot (ie. commenting /replace ...) which is what the bot is aimed for as opposed to bots like alex-lint or others who would automatically look at the words used and react accordingly.

Konard commented 4 years ago

Something like orthographic-pedant should be revived but as opt-in bot.