Creating pull requests with GPT3 and random artwork

A friend of mine has been retweeting great paintings from Twitter accounts like @HenryRothwell, which I’ve greatly enjoyed. E.g.

In a similar vein, I’ve started embedding painting images in the description of every pull request I open. E.g.

image

I create pull requests with:

git createpr

where createpr is an alias to hub pull-request with pre-populated options:

# ~/.gitconfig

createpr = !hub pull-request --draft --browse --edit
    --message=\"$(pull-request-title)\"
    --message=\"$(pull-request-summary)\"
    --message=\"$(random-picture)\"

The pull request body is built by joining the --message options separated by a blank line. Each message component has its own script:

  • pull-request-title is a Bash script that uses the OpenAI API to summarise the commit messages into a pull request title. I haven’t quite found the right prompt text to work here — that’s a work-in-progress.

  • pull-request-summary is a simple Python script that combines all the commit messages and removes the hard line wrapping1. The output will generally need some editing before it’s suitable (hence the --edit option in the alias) but it’s a good starting point.

  • random-picture is a Python script that plucks a randomly selected image from a set of Twitter accounts and prints the appropriate markdown.

This works nicely — the painting images even unfurl elegantly in Slack.

image


  1. Commit messages are hard-wrapped at 72 characters but pull request descriptions shouldn’t be hard wrapped. ↩︎

——————

Something wrong? Suggest an improvement or add a comment (see article history)
Tagged with: Github, OpenAI
Filed in: projects

Previous: New project: Food price scraper
Next: Tips for using Github Copilot in Vim

Copyright © 2005-2024 David Winterbottom
Content licensed under CC BY-NC-SA 4.0.