SHA256
1
0
Fork
You've already forked submodules
0
Handle project dependencies stored in external git repositories
  • Zig 100%
Find a file
Dirk Zimmermann 8f0117d97a Build/Install
2026年04月09日 17:12:04 +02:00
src Put "git" in front 2026年04月04日 10:31:03 +02:00
.gitignore Ignore testing submodule pEpForiOS.XCFrameworks/ 2026年04月01日 16:26:38 +02:00
.submodules.json Update submodules 2026年04月01日 17:01:22 +02:00
build.zig Rename to "submodules" 2026年04月01日 12:15:40 +02:00
build.zig.zon Rename to "submodules" 2026年04月01日 12:15:40 +02:00
LICENSE Initial commit 2026年03月22日 08:41:08 +01:00
README.md Build/Install 2026年04月09日 17:12:04 +02:00

submodules

Handle project dependencies stored in external git repositories.

It's all git for now, but there's no reason not to extend this to other version control systems.

It expects a local file .submodules.json to read submodule info from, and updates this file with certain commands.

Example .submodules.json:

[
 {
 "url": "https://github.com/randombit/botan.git",
 "path": "botan",
 "commit": "3a4ae17b0d48da54f380d47bdc33779340e6e3e7"
 },
 {
 "url": "ssh://git@codeberg.org/pEp/vks-client.git",
 "path": "vks-client",
 "commit": "088abdd6b94003f60eb8d139f781874cdbffcd08aeccf53b451fbebc059eb337"
 },
 {
 "url": "ssh://git@codeberg.org/pEp/libetpan.git",
 "path": "libetpan",
 "commit": "960de72c05e61611c0ba55332e9799dce7b605c3"
 },
 {
 "url": "ssh://git@codeberg.org/pEp/pEpForiOS.XCFrameworks.git",
 "path": "pEpForiOS.XCFrameworks"
 }
]

Build/Install

zig fetch --save https://github.com/Hejsil/zig-clap/archive/refs/tags/0.11.0.tar.gz
zig build --prefix $HOME/.local

Make sure $HOME/.local/bin is in your PATH.

Commands

Commands are run via zig build run -- <command>, or submodules <command> if you installed this tool.

  • clone - recursively clones all submodules from their respective repository.
  • status - executes git status for all submodules.
  • branch - outputs the current branch name of every submodule, if available, otherwise the current commit.
  • fixate - (not recursively) write the current commit hash of every direct submodule to the local .submodules.json.
  • checkout - recursively checks out the previously written commit of every submodule (via fixate).

Build and run directly

For development:

zig build run -- <command>

Motivation

Git submodules can be great if they match your use case, but they break apart spectacularly when you want to mix SHA-1 and SHA-256 repositories.

There are clusters of projects that use something like known_good.json to handle such dependencies/subrepositories manually, with scripting involved. Each repo with its own rules and scripts.

Submodules is my attempt to solve this "once and for all" in one place for my personal use cases, without ever again getting broken by hash algorithm transitions, or getting pinned to one particular VCS.