ups/README.md
ngn ba1f0284c3
All checks were successful
format / format (push) Successful in 16s
remove the release workflow
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-12 21:46:13 +03:00

3.2 KiB

ups | upstream scripts

collection of bash and python scripts for pulling and managing patches from the upstream git repos of my personal forks

installation

you'll need the following dependencies to install and use ups:

  • make
  • pypa build package
  • git
  • python(3)
  • python requests module
  • GNU bash coreutils
  • sed

after installing these tools, you can just clone the main branch and run the make script to build python library, then you can run the install make script to install the library and the scripts:

git clone https://git.ngn.tf/ngn/ups
cd ups
make && make install

usage

first navigate to your repo and a ups.json file

this file should specify the upstream URL, and the provider for the upstream, currently gitea and github are the only supported providers

for example here is my configuration for the 4get repo:

{
  "upstream": "https://git.lolcat.ca/lolcat/4get",
  "provider": "gitea"
}

you should also specify the last commit you got from upstream, unless you are on the last commit:

...
  "commit": "78aa2e198f11ca928891ec83ef97d2445147414a"
...

now to check for any upstream commits, you run ups-check, this script simply checks the last commit and compares it to the commit you specified in the configuration

if you did not specfiy a commit it assumes you are on the latest commit, otherwise it compares the last commit ID with the current commit ID to see if you are on the latest commit

if this is not the case, then it checks how many commits have been made between these two commits

to actually apply these commits to your repo, as in the form of patches, you need to run ups-update

this script will download all the commits as patches, and give you and option to modify or skip them before applying them

it will also update the commit hash you specified in the configuration, when you apply all the commits you want, you'll also need to run ups-commit in order to commit the changes made to your configuration file

scripts

ups allows you to run custom sed script on the commit patches before applying them, so you don't need to edit all of them just to do some simple modifications every time

for example, in the 4get repo, i placed all the php source code to src directory, which is not the case in the upstream

so i added these two scripts to my configuration to automatically fix the diff paths of the patches:

...
  "scripts": [
    "s/--- a\\//--- a\\/src\\//g",
    "s/+++ b\\//+++ b\\/src\\//g"
  ]
...

workflow

here's an example gitea workflow action to run ups every week and check for any upstream updates:

name: ups

on:
  schedule:
    - cron: "@weekly"

jobs:
  ups:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          sudo apt update -y
          sudo apt install -y python3 python3-build python3-requests make

      - name: Install ups
        run: |
          git clone https://git.ngn.tf/ngn/ups && cd ups
          make && make install

      - name: Run ups
        run: PATH=~/.local/bin:$PATH ups-check