Pushing patches to sr.ht git repos

January 6, 2022 0 By addshore

I recently wrote a blog post using the taavi/laravel-socialite-mediawiki PHP library which is hosted on sr.ht.

sr.ht, or sourcehut is “is a collection of tools useful for software development”, including git repository hosting.

I had to make a change to the library, and this was my first time contributing to a sr.ht repository. The workflow was quite different from what I am used to and required quite some Googling before I came up with something that I was happy with. So here goes my workflow.

Workflow

Firstly, if you haven’t used sr.ht before you’ll need to create an account and set up some way of pushing code (SSH keys etc). There are some fairly good docs for this already for Setting up your account and first git repository, but you can stop at Creating a git repository.

Once you have an account set up you need to find the sr.ht repository that you want to work with. In my case that is at the URL https://git.sr.ht/~taavi/laravel-socialite-mediawiki

You can find a clone URL over on the right-hand side of the repo page, and you want to go ahead and clone the repo.

git clone https://git.sr.ht/~taavi/laravel-socialite-mediawikiCode language: PHP (php)

You then also want to fork the repo into your own sr.ht account. The button is also on the right.

(You can also use your local clone to send a git email, but I didn’t want to install this tooling)

Screenshot of a sr.ht repository with the clone information highlighted

You can now also navigate to your fork, in my case https://git.sr.ht/~addshore/laravel-socialite-mediawiki and add this remote to your existing local repo. I’m going to call my remote addshore.

git remote add addshore git@git.sr.ht:~addshore/laravel-socialite-mediawiki

You can now make your change locally in a branch, and push it to your fork of the repository.

# Checkout a new branch for your changes
git checkout -b my-new-branch

# Change your files and add them to a git commit
git commit

# Push then to your fork
git push addshore my-new-branchCode language: PHP (php)

When browsing your fork you’ll find a button prompting you to “Prepare a patchset”. Click this!

Screenshot of a forked sr.ht repository with the prepare patchset information highlighted

You should be able to see the branch that you just pushed, and then selecting the branch you’ll also be able to see the commit that you just made. If this all looks good you can click the “Continue” button at the bottom.

Screenshot of selecting a branch to submit a patch from on sr.ht

Next, you’ll be prompted for some more information. The patchset revision should be 1 to start with, and if you want to amend in the future and send new patches this can be incremented. You can also write a cover letter describing the patch that you are submitting.

Once done here you can hit the “Continue” button again.

Screenshot adding a cover level to a sr.ht patch for submission

Finally, you need to say who you are sending this patch to. For me this is detailed in the README of the repo that I want to contribute to, and is ~taavi/inbox@lists.sr.ht

Enter the email, optionally CC yourself, and hit “Send patchset”

Screenshot selecting an email to send a sr.ht patch to

Your patchset should now be sent, and you can go and view this in the inbox that you sent it to.

For my patch, the inbox is at https://lists.sr.ht/~taavi/inbox and my patch specifically is 27991