Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/actions/setup-moonbit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ inputs:
version:
description: MoonBit toolchain version
required: false
# v0.10.7 ICEs while compiling moonbitlang/x@0.4.43. Keep CI on the
# last verified compiler until an upstream release fixes that regression.
default: "0.10.6+80dc50f24"
# Keep this on the toolchain the workspace is verified against: the
# dependency pins in modules/*/moon.mod (moonbitlang/async 0.22,
# moonbitlang/x 0.5, bobzhang/toml 0.4) need the 2026-09 compiler.
default: "0.10.13+cbb11c36f"

runs:
using: composite
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ jobs:
- name: Build native binary for wbtests
run: |
set -euo pipefail
# moonc 0.10.13's link-core pass overflows the default 8 MiB stack
# on cmd/bit's debug build (ICE: "Stack overflow"); the release
# build is unaffected. Lift the limit for this process tree.
ulimit -s unlimited
moon --version
moon build --target native modules/bit
bin_path=$(find _build/native -maxdepth 8 -type f -name 'bit.exe' | head -1)
Expand All @@ -209,6 +213,7 @@ jobs:
timeout-minutes: ${{ matrix.timeout }}
run: |
set -euo pipefail
ulimit -s unlimited # see "Build native binary for wbtests"
if [ "${{ matrix.kind }}" = "pkg" ]; then
moon test --target native -p ${{ matrix.sel }}
else
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ version.ts
xxxx
.bench-baseline
.local
npm/bit.cjs
npm/bit.mjs
npm/lib.raw.js
/result
apps/
Expand Down
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ toolchain to the latest release when it is older than that, so Claude Code web
sessions get a working native backend automatically. `moon build --target
native --release` (the `bit.exe` binary) already uses `cc`, so it is
unaffected.

On toolchain `0.10.13` the debug build of `modules/bit` (`moon build --target
native modules/bit`, and `moon test` on `cmd/bit`) makes moonc's link-core pass
overflow the default 8 MiB stack and abort with an ICE (`Error: Stack
overflow`). Run `ulimit -s unlimited` first; the release build is unaffected.
18 changes: 9 additions & 9 deletions Taskfile.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ local syncNpmLibRaw: Task = new {
outputs { "npm/lib.raw.js" }
}

local syncNpmBitCjs: Task = new {
name = "sync-npm-bit-cjs"
description = "Copy the JS CLI payload into the checked-in npm wrapper"
cmd = "cp _build/js/release/build/mizchi/bit/bit.js npm/bit.cjs"
local syncNpmBitMjs: Task = new {
name = "sync-npm-bit-mjs"
description = "Copy the JS CLI payload (ES module) into the checked-in npm wrapper"
cmd = "cp _build/js/release/build/mizchi/bit/bit.js npm/bit.mjs"
deps { buildJsCli }
inputs { "_build/js/release/build/mizchi/bit/bit.js" }
outputs { "npm/bit.cjs" }
outputs { "npm/bit.mjs" }
}

local buildNpm: Task = new {
name = "build-npm"
description = "Build the JS lib + CLI and stage them into npm/ for publish"
deps { syncNpmLibRaw; syncNpmBitCjs }
deps { syncNpmLibRaw; syncNpmBitMjs }
}

local bundleJsLibMinimal: Task = new {
Expand Down Expand Up @@ -295,7 +295,7 @@ local test: Task = new {
deps {
build
syncNpmLibRaw
syncNpmBitCjs
syncNpmBitMjs
bundleJsLibMinimal
bundleJsLibGitOps
}
Expand All @@ -316,7 +316,7 @@ local testJsBuild: Task = new {
cmd = "node --test tools/js-build.test.mjs tools/npm-lib.test.mjs tools/npm-cli.test.mjs tools/demo-relay.test.mjs tools/demo-editor-link.test.mjs tools/playground-commands.test.mjs tools/playground-view.test.mjs tools/flaker-affected-rules.test.mjs tools/select-affected-tests.test.mjs"
deps {
syncNpmLibRaw
syncNpmBitCjs
syncNpmBitMjs
bundleJsLibMinimal
bundleJsLibGitOps
}
Expand Down Expand Up @@ -686,7 +686,7 @@ tasks {
buildJsLib
buildJsCli
syncNpmLibRaw
syncNpmBitCjs
syncNpmBitMjs
buildNpm
bundleJsLibMinimal
bundleJsLibGitOps
Expand Down
6 changes: 3 additions & 3 deletions component/moon.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"mizchi/bit": {
"path": ".."
},
"mizchi/zlib": "0.3.0",
"moonbitlang/x": "0.4.40",
"mizchi/x": "0.1.4"
"mizchi/zlib": "0.4.9",
"moonbitlang/x": "0.5.5",
"mizchi/x": "0.6.1"
},
"license": "Apache-2.0",
"description": "WASM Component for bit-vcs git operations"
Expand Down
26 changes: 13 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions modules/bit/cmd/bit/am.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ async fn handle_am(args : Array[String]) -> Unit raise Error {
if fs.is_file(next_file) {
let next = fs.read_file(next_file) |> decode_bytes |> trim_string
let n = @string.parse_int(next) catch {
err if @async.is_cancellation_error(err) => raise err
_ => 1
}
fs.write_string(next_file, (n + 1).to_string())
Expand Down Expand Up @@ -278,11 +277,9 @@ async fn apply_remaining_patches(
let last_str = fs.read_file(am_dir + "/last") |> decode_bytes |> trim_string
let next_str = fs.read_file(am_dir + "/next") |> decode_bytes |> trim_string
let last = @string.parse_int(last_str) catch {
err if @async.is_cancellation_error(err) => raise err
_ => 0
}
let mut next = @string.parse_int(next_str) catch {
err if @async.is_cancellation_error(err) => raise err
_ => 1
}
while next <= last {
Expand Down
9 changes: 0 additions & 9 deletions modules/bit/cmd/bit/bisect.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ async fn bisect_mark(
}
let log_entry = "# \{mark_type}: [\{commit_hex}] \{commit_msg}\ngit bisect \{mark_type} \{commit_hex}\n"
let existing_log = decode_bytes(rfs.read_file(bisect_log_path)) catch {
err if @async.is_cancellation_error(err) => raise err
_ => ""
}
wfs.write_string(bisect_log_path, existing_log + log_entry)
Expand Down Expand Up @@ -185,7 +184,6 @@ async fn bisect_skip(
wfs.write_string(bisect_refs_dir + "/skip-" + commit_hex, commit_hex + "\n")
let log_entry = "git bisect skip \{commit_hex}\n"
let existing_log = decode_bytes(rfs.read_file(bisect_log_path)) catch {
err if @async.is_cancellation_error(err) => raise err
_ => ""
}
wfs.write_string(bisect_log_path, existing_log + log_entry)
Expand All @@ -210,7 +208,6 @@ fn bisect_compute_next(
let good_commits : Array[@bitcore.ObjectId] = []
let skip_commits : Array[@bitcore.ObjectId] = []
let bisect_entries = (rfs : &@bitcore.RepoFileSystem).readdir(bisect_refs_dir) catch {
err if @async.is_cancellation_error(err) => raise err
_ => []
}
for entry in bisect_entries {
Expand Down Expand Up @@ -392,7 +389,6 @@ async fn bisect_verify_good(
let bisect_refs_dir = git_dir + "/refs/bisect"
// Find a good commit
let bisect_entries = (rfs : &@bitcore.RepoFileSystem).readdir(bisect_refs_dir) catch {
err if @async.is_cancellation_error(err) => raise err
_ => []
}
let mut good_hex : String? = None
Expand Down Expand Up @@ -516,7 +512,6 @@ async fn bisect_visualize(
// Collect good commits for --not
let good_hexes : Array[String] = []
let bisect_entries = (rfs : &@bitcore.RepoFileSystem).readdir(bisect_refs_dir) catch {
err if @async.is_cancellation_error(err) => raise err
_ => []
}
for entry in bisect_entries {
Expand Down Expand Up @@ -617,22 +612,18 @@ async fn bisect_reset(
]
for path in cleanup_files {
wfs.remove_file(path) catch {
err if @async.is_cancellation_error(err) => raise err
_ => ()
}
}
let entries = (rfs : &@bitcore.RepoFileSystem).readdir(bisect_refs_dir) catch {
err if @async.is_cancellation_error(err) => raise err
_ => []
}
for entry in entries {
wfs.remove_file(bisect_refs_dir + "/" + entry) catch {
err if @async.is_cancellation_error(err) => raise err
_ => ()
}
}
wfs.remove_file(bisect_refs_dir) catch {
err if @async.is_cancellation_error(err) => raise err
_ => ()
}
eprint_line("Bisect reset")
Expand Down
118 changes: 56 additions & 62 deletions modules/bit/cmd/bit/cat.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -67,71 +67,65 @@ async fn handle_cat(args : Array[String]) -> Unit raise Error {
}
let path = @bitlib.normalize_repo_path(raw_path)
let temp_dir = make_temp_dir(fs, "bit-cat")
try {
let _ = @bitnative.clone_http_to_fs(
remote_url,
true,
fs,
temp_dir,
fs,
depth=1,
filter=@protocol.FilterSpec::BlobNone,
)
let git_dir = temp_dir + "/.git"
let commit_id = match ref_spec {
Some(refname) => {
let resolved = resolve_remote_ref_id(remote_url, refname)
guard resolved is Some((id, _)) else {
raise @bitcore.GitError::InvalidObject("Unknown ref: " + refname)
}
id
}
None => {
let head_id = @bitrepo.rev_parse(fs, git_dir, "HEAD")
guard head_id is Some(id) else {
raise @bitcore.GitError::InvalidObject("HEAD not found")
}
id
errdefer remove_dir_recursive(fs, temp_dir)
let _ = @bitnative.clone_http_to_fs(
remote_url,
true,
fs,
temp_dir,
fs,
depth=1,
filter=@protocol.FilterSpec::BlobNone,
)
let git_dir = temp_dir + "/.git"
let commit_id = match ref_spec {
Some(refname) => {
let resolved = resolve_remote_ref_id(remote_url, refname)
guard resolved is Some((id, _)) else {
raise @bitcore.GitError::InvalidObject("Unknown ref: " + refname)
}
id
}
let mut db = @bitlib.ObjectDb::load_lazy(fs, git_dir)
if db.get(fs, commit_id) is None {
let pack = @bitnative.fetch_pack_http(remote_url, [commit_id], true)
let objects = @pack.parse_packfile(pack)
@pack.write_packfile_with_index(fs, git_dir, pack, objects)
db = @bitlib.ObjectDb::load_lazy(fs, git_dir)
}
let tree_id = resolve_to_tree(db, fs, commit_id)
let entry = @bitlib.find_tree_entry(db, fs, tree_id, path)
guard entry is Some(found) else {
raise @bitcore.GitError::InvalidObject("path not found: " + path)
}
let is_tree = found.mode == "40000" || found.mode == "040000"
let is_submodule = found.mode == "160000"
if is_tree {
raise @bitcore.GitError::InvalidObject("path is a tree: " + path)
}
if is_submodule {
raise @bitcore.GitError::InvalidObject("path is a submodule: " + path)
}
let mut obj = db.get(fs, found.id)
if obj is None {
let wants : Array[@bitcore.ObjectId] = [found.id]
let pack = @bitnative.fetch_pack_http(remote_url, wants, true)
let objects = @pack.parse_packfile(pack)
@pack.write_packfile_with_index(fs, git_dir, pack, objects)
let db2 = @bitlib.ObjectDb::load_lazy(fs, git_dir)
obj = db2.get(fs, found.id)
}
guard obj is Some(blob) else {
raise @bitcore.GitError::InvalidObject("blob not found: " + path)
}
@stdio.stdout.write(blob.data)
} catch {
err => {
remove_dir_recursive(fs, temp_dir)
raise err
None => {
let head_id = @bitrepo.rev_parse(fs, git_dir, "HEAD")
guard head_id is Some(id) else {
raise @bitcore.GitError::InvalidObject("HEAD not found")
}
id
}
}
let mut db = @bitlib.ObjectDb::load_lazy(fs, git_dir)
if db.get(fs, commit_id) is None {
let pack = @bitnative.fetch_pack_http(remote_url, [commit_id], true)
let objects = @pack.parse_packfile(pack)
@pack.write_packfile_with_index(fs, git_dir, pack, objects)
db = @bitlib.ObjectDb::load_lazy(fs, git_dir)
}
let tree_id = resolve_to_tree(db, fs, commit_id)
let entry = @bitlib.find_tree_entry(db, fs, tree_id, path)
guard entry is Some(found) else {
raise @bitcore.GitError::InvalidObject("path not found: " + path)
}
let is_tree = found.mode == "40000" || found.mode == "040000"
let is_submodule = found.mode == "160000"
if is_tree {
raise @bitcore.GitError::InvalidObject("path is a tree: " + path)
}
if is_submodule {
raise @bitcore.GitError::InvalidObject("path is a submodule: " + path)
}
let mut obj = db.get(fs, found.id)
if obj is None {
let wants : Array[@bitcore.ObjectId] = [found.id]
let pack = @bitnative.fetch_pack_http(remote_url, wants, true)
let objects = @pack.parse_packfile(pack)
@pack.write_packfile_with_index(fs, git_dir, pack, objects)
let db2 = @bitlib.ObjectDb::load_lazy(fs, git_dir)
obj = db2.get(fs, found.id)
}
guard obj is Some(blob) else {
raise @bitcore.GitError::InvalidObject("blob not found: " + path)
}
@stdio.stdout.write(blob.data)
remove_dir_recursive(fs, temp_dir)
}
Loading
Loading