Julia tooling that keeps the JuliaGiac forks in sync with Bernard Parisse's upstream releases of Giac.
Upstream does not use a public version control system: releases are
published as tarballs (giac-X.Y.Z.tar.gz) with an md5sum.txt in
https://www-fourier.univ-grenoble-alpes.fr/~parisse/giac/. This project
turns each tarball into a tagged commit of the fork, prepares the merge of
that release into our fork, and lists our fixes so that they can be sent
back upstream.
Nothing here ever pushes, opens pull requests or posts anything: every command works on a local clone and prints the next steps.
Each fork (configured in upstreams.toml) has two
long-lived branches:
| Branch | Content |
|---|---|
main |
the pristine upstream tree, one commit per imported release, imported from the release tarball through a pull request and tagged upstream/X.Y.Z once merged. The only non-upstream files are the kept paths (for giac: .github/, the Dependabot configuration). |
dev |
our fork: Meson build, fixes, tests, site, CI. Upstream releases reach dev by merging main (or the import branch). |
So git diff upstream/X.Y.Z dev is exactly "what we changed", and
git diff upstream/A upstream/B is exactly "what upstream changed".
Only giac (JuliaGiac/giac) is
configured. On its dev branch, MicroPython (micropython/, replacing
upstream's vendored micropython-1.12/) and the Xcas FLTK GUI
(s-celles/xcas, extracted from the giac
tarball) are git submodules and are deliberately not synced with
upstream: Giac.jl only needs libgiac. Their upstream paths, like the
autotools files replaced by Meson, are listed in fork_excluded_paths so
that merge-plan treats upstream changes to them as expected.
Requirements: Julia ≥ 1.10, git ≥ 2.28 and tar (with gzip/bzip2/xz)
on the PATH.
git clone https://github.com/JuliaGiac/upstream-sync.git
cd upstream-sync
julia --project=. -e 'using Pkg; Pkg.instantiate()' # or: just instantiate
julia --project=. bin/upstream-sync.jl [--config FILE] [--cache DIR] <command> ...
With just: just check, just import giac 2.1.0 ../giac, just tag giac 2.1.0 ../giac, just merge-plan giac 2.1.0 ../giac, just export giac ../giac.
Lists the release versions found in the upstream index, the latest one and
the latest imported one (the highest upstream/X.Y.Z tag, read with
git ls-remote --tags from the GitHub repository, or from --repo), and
reports whether a newer release exists. Without NAME, every configured
upstream is checked. --github-output appends
new_releases=<name> <X.Y.Z>,... and status=... to $GITHUB_OUTPUT.
In a local clone of the fork:
- downloads
giac-X.Y.Z.tar.gzandmd5sum.txt(the tarball is cached incache/, or$UPSTREAM_SYNC_CACHE, and reused; the checksum file is always refreshed unless--offline) and verifies the checksum; - extracts the tarball and strips its top directory;
- creates the branch
upstream-import/X.Y.Zfrommainwith one commit whose tree is exactly the tarball (bytes as published: no.gitignore,.gitattributesor end-of-line filtering; file modes from the tar headers) plus the kept paths ofmain. The commit is "import upstream giac X.Y.Z", with the source URL, the checksum and the tree hash (Tree: <hash>) in its body; author and committer are your local git identity.
It does not tag: the pull request may be merged with a method that
rewrites the commit (squash, rebase), so the tag is created afterwards by
tag.
The working tree and index of the clone are not touched (the commit is
built with a temporary index). Nothing is pushed; the next steps are
printed. --force replaces an existing branch and tag.
The import refuses to start when the local main differs from main on
origin (read with git ls-remote origin): an import based on a stale
main would, for instance, drop the kept .github/ files committed since.
Update it first (git fetch origin main:main) or pass --allow-stale.
Run once the import pull request is merged, with any merge method:
- fetches
mainfromorigin(unless--offline); - finds the commit of
origin/mainwith the tree of the import: the import commit itself if it is onmain(merge commit, fast-forward), otherwise the oldest commit with the same tree (squash, rebase). The import tree is read from theupstream-import/X.Y.Zbranch (local ororigin/), or, if that branch was deleted, from the "import upstream giac X.Y.Z" commit onmain(itsTree:line, or its own tree); - creates the annotated tag
upstream/X.Y.Zthere, with the source URL and checksum of the import.
It refuses when no commit of main has that tree (pull request not merged
yet) or when upstream/X.Y.Z already exists on another commit (--force
moves it); it is a no-op when the tag is already right. It prints the
git push origin upstream/X.Y.Z command and never pushes.
merge-plan NAME X.Y.Z --repo PATH [--output FILE] [--force] [--allow-stale] [--resolve-expected [--worktree DIR]]
Creates the branch sync/X.Y.Z from dev, tries
git merge --no-commit upstream-import/X.Y.Z on it (in a temporary
worktree), aborts the merge, and writes a Markdown report
(merge-plan-<name>-X.Y.Z.md by default) with:
- the files changed upstream (added/modified/deleted, lines, per area);
- the upstream changes touching files we modified on
dev; - the expected conflicts: "deleted by us" conflicts on
fork_excluded_paths(filesdevintentionally does not carry, such asmicropython-1.12/, the Xcas GUI sources and the autotools build), to be resolved by keeping the deletion; - the excluded additions: files upstream added under
fork_excluded_paths.git mergeadds them todevwithout a conflict (2.1.0 brought back tenmicropython-1.12/files this way), so they are listed apart, to be removed; - the new upstream files outside
fork_excluded_paths: they merge cleanly, but the Meson build may need to list them (2.1.0 addedsrc/proba.ccand its test); - the real conflicts grouped by area: Meson/build, src fixes, docs,
other (areas are configured in
upstreams.toml), with their kind ("both modified", "deleted by us", ...).
Like import, it refuses a local dev that differs from origin's unless
--allow-stale.
With --resolve-expected, the merge is not aborted: it is left in progress
in a worktree of sync/X.Y.Z (default: <repo>-sync-X.Y.Z next to the
clone, or --worktree DIR), with the expected conflicts and the excluded
additions removed by git rm and the real conflicts still marked. Nothing is committed: finish the
merge there, then git worktree remove it.
Lists our changes to the upstream sources, as Markdown: the commits of
dev that are not on main and modify the configured source paths (for
giac src/ and check/, without meson.build files), oldest first, each
with date, hash, subject and GitHub URL
(https://github.com/JuliaGiac/giac/commit/<hash>), and the diffstat of
main...dev on those paths. This is what the maintainer sends upstream as
links.
| Status | Meaning |
|---|---|
| 0 | success; for check: every upstream is up to date |
| 1 | error (message on stderr) |
| 10 | check only: a release newer than the latest upstream/X.Y.Z tag exists |
The weekly workflow check-upstream.yml
runs check and opens (or updates) an issue "New upstream release: giac
X.Y.Z" in this repository. Then, for giac X.Y.Z:
- Check (optional, the issue already did it):
julia --project=. bin/upstream-sync.jl check giac - Import into an up-to-date clone of the fork:
Review it:
git -C ../giac fetch origin && git -C ../giac branch -f main origin/main julia --project=. bin/upstream-sync.jl import giac X.Y.Z --repo ../giacgit -C ../giac show --stat upstream-import/X.Y.Z. - Publish the import (this tool never pushes):
Merge that pull request with any method (merge commit, squash or rebase).
git -C ../giac push origin upstream-import/X.Y.Z gh pr create --repo JuliaGiac/giac --base main --head upstream-import/X.Y.Z \ --title "import upstream giac X.Y.Z" - Tag the merged commit, then push the tag:
julia --project=. bin/upstream-sync.jl tag giac X.Y.Z --repo ../giac git -C ../giac push origin upstream/X.Y.Zcheckreads theseupstream/X.Y.Ztags as the imported versions. - Plan the fork update (with
devup to date:git -C ../giac pull --ff-only):Readjulia --project=. bin/upstream-sync.jl merge-plan giac X.Y.Z --repo ../giac \ --resolve-expectedmerge-plan-giac-X.Y.Z.md: expected and real conflicts, excluded additions, upstream changes on files we patched, and the new upstream files (add new sources and tests to the Meson build). A "deleted by us" real conflict is a filedevremoved outsidefork_excluded_paths: keep the deletion or restore the file, and updatefork_excluded_pathsif the removal is intended. - Merge into dev: in the worktree
../giac-sync-X.Y.Z(branchsync/X.Y.Z, merge in progress, expected conflicts and excluded additions already removed), resolve the real conflicts, bump the version inmeson.build, run the tests,git commit, pushsync/X.Y.Zand open a pull request todev. Thengit -C ../giac worktree remove ../giac-sync-X.Y.Z. - Send our fixes upstream:
julia --project=. bin/upstream-sync.jl export giac --repo ../giac --output fixes.mdand send the links of the relevant commits to Bernard Parisse. - Close the issue.
See the comments at the top of upstreams.toml and the
documentation.
just test # julia --project=. -e 'using Pkg; Pkg.test()'
just docs # build the documentation (warnings are errors)
just llms # regenerate llms.txt and llms-full.txt
Tests use TestItemRunner and run fully offline: a saved copy of the upstream index, and a tiny synthetic fork and release site generated on the fly.
GPL-3.0-or-later, see LICENSE.