From 71d052a0afd9e9170cd6f8d9caafea0891c46d86 Mon Sep 17 00:00:00 2001 From: Mike Boiko Date: Mon, 23 Mar 2026 06:10:58 -0600 Subject: [PATCH] ci: automate fork sync workflow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/rebase-patches.yml | 49 ++++++++++++++++++++++++++++ .github/workflows/sync-upstream.yml | 45 +++++++++++++++++++++++++ README.md | 18 ++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .github/workflows/rebase-patches.yml create mode 100644 .github/workflows/sync-upstream.yml diff --git a/.github/workflows/rebase-patches.yml b/.github/workflows/rebase-patches.yml new file mode 100644 index 000000000..299b405a2 --- /dev/null +++ b/.github/workflows/rebase-patches.yml @@ -0,0 +1,49 @@ +name: Rebase patches + +on: + workflow_dispatch: + workflow_run: + workflows: + - Sync upstream + types: + - completed + +permissions: + contents: write + +concurrency: + group: rebase-patches + cancel-in-progress: false + +jobs: + rebase-patches: + name: Rebase my-patches onto main + if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: my-patches + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Fetch main and patch branches + run: | + git fetch origin \ + +refs/heads/main:refs/remotes/origin/main \ + +refs/heads/my-patches:refs/remotes/origin/my-patches + + git show-ref --verify --quiet refs/remotes/origin/main + git show-ref --verify --quiet refs/remotes/origin/my-patches + + - name: Rebase patch branch + run: | + git checkout my-patches + git rebase refs/remotes/origin/main + + - name: Push my-patches + run: git push --force-with-lease origin my-patches diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 000000000..772ac4e1b --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,45 @@ +name: Sync upstream + +on: + schedule: + - cron: "17 * * * *" + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: sync-upstream + cancel-in-progress: false + +jobs: + sync-main: + name: Sync main from upstream + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: main + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Fetch upstream main + run: | + if git remote get-url upstream >/dev/null 2>&1; then + git remote set-url upstream https://github.com/nvim-treesitter/nvim-treesitter.git + else + git remote add upstream https://github.com/nvim-treesitter/nvim-treesitter.git + fi + git fetch upstream +refs/heads/main:refs/remotes/upstream/main + + - name: Rebase fork metadata onto upstream + run: | + git checkout main + git rebase refs/remotes/upstream/main + + - name: Push main + run: git push --force-with-lease origin main diff --git a/README.md b/README.md index 94206aa31..516747b50 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,24 @@ It is strongly recommended to automate this; e.g., using the following spec with >[!IMPORTANT] > This plugin does not support lazy-loading. +## Using this fork + +If you are installing `mikeboiko/nvim-treesitter`, use `branch = 'my-patches'` in your plugin manager. The `main` branch is reserved for tracking upstream plus the small fork-maintenance commits that keep this repository in sync automatically. + +This fork uses two GitHub Actions workflows: + +- `Sync upstream` rebases the fork-maintenance commits on top of `nvim-treesitter/main` and force-pushes `main`. +- `Rebase patches` rebases `my-patches` on top of `main` and force-pushes it when the rebase succeeds. + +If `Rebase patches` reports a conflict, resolve it locally with: + +```sh +git checkout my-patches +git fetch origin upstream +git rebase origin/main +git push --force-with-lease origin my-patches +``` + ## Setup `nvim-treesitter` can be configured by calling `setup`. **You do not need to call `setup` for `nvim-treesitter` to work using default values.**