I’m on holiday now. No deadlines, no rush (at least for a few days). I’m setting aside some time to automate a few daily tasks, the automation I’ve been putting off for a while.

One thing I constantly find myself doing is digging through other people’s code on GitHub, trying to see if someone has already solved the problem I’m facing.

Most recently, this happened while I was working with tiktok-uploader. I had been manually uploading my TikTok videos for some time before moving to this tool (yeah, I know there’s an official API, but for a few reasons, I wanted to stick with a Selenium-based approach.).

The problem is that the video scheduling feature is broken. I am sure someone must’ve already fixed it. Let’s write a quick script to find that “someone”.

#!/bin/zsh

Owner="wkaisertexas"
Repo="tiktok-uploader"

git clone "https://github.com/${Owner}/${Repo}.git"
cd "$Repo"

page=1

while true; do

    url="https://api.github.com/repos/${Owner}/${Repo}/forks?per_page=100&page=${page}"

    forks=$(curl "$url")

    count=$(echo $forks | jq 'length')

    if [ "$count" -eq 0 ]; then
        break
    fi

    echo "$forks" | jq -c '.[]' | while read -r fork; do
        login=$(echo "$fork" | jq -r '.owner.login')
        clone_url=$(echo "$fork" | jq -r '.clone_url')
        git remote add "$login" "$clone_url"
    done

    ((++page))
done

git fetch --all

Here’s what it does:

  • Clones the upstream repository.
  • Fetches the list of forks (GitHub limits these API calls to 60 per hour).
  • Adds each fork as a remote.
  • Finally, runs git fetch --all to pull all commits from every remote (aka all forks) into the local repo.

Now that I’ve got all the commits locally, I can start hunting for the commits I care about:

git log --grep schedule --remotes --not main

This searches for commits that aren’t on main (since we already know the fix isn’t there) and that mention “schedule” in their message.

commit 051253dbeb3e83e671554b877ea4c084445010d7
Author: martin-nb995 <[email protected]>
Date:   2025-05-10 14:40:58 +0200

    updated xpaths for schedule release and some small fixes

commit eed9215cd94fe139cf6f85acfdbe76fa1e2e3e29
Author: Franklin May <[email protected]>
Date:   2024-01-28 19:33:45 -0500

    Update upload.py

    I think add more time.sleep(config['implicit_wait']) to def complete_upload_form in upload.py

        time.sleep(config['implicit_wait'])
        #  _remove_cookies_window(driver)
        _set_video(driver, path=path, **kwargs)
        time.sleep(config['implicit_wait'])
        _remove_split_window(driver)
        time.sleep(config['implicit_wait'])
        _set_interactivity(driver, **kwargs)
        time.sleep(config['implicit_wait'])
        _set_description(driver, description)
        time.sleep(config['implicit_wait'])
        if schedule:
            _set_schedule_video(driver, schedule)
        _post_video(driver)



    Hopefully fix selenium porblem

Bam! Found it right in the first shot. The first commit is what I needed (I later found out that this commit was part of a rejected PR. Anyway, I did not need the rejected portion, and only picked the changes I was interested in).

It happens all the time. You run into some issue in an open-source project, dig through the forks, and discover that someone has already solved it. Maybe their pull request is still pending/rejected, maybe it’s just a personal patch that never got merged. It’s especially common with softwares that constantly need patching, things like web scrapers, API wrappers, or anything that relies on ever-changing third-party sites.

It works great if there are only a few forks. But if a project has hundreds, doing this manually can get really tedious.

Funny enough, while writing this post, I ran into issues with the tooling I use to publish it, and I reached for this exact script. Full circle.