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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target/
target
.mooncakes/
.moonagent/
.flaker/
.repos/
.jj/tools/git-shim/shim.log
tools/git-shim/shim.log
Expand Down
28 changes: 28 additions & 0 deletions flaker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[repo]
owner = "bit-vcs"
name = "bit"

[storage]
path = ".flaker/data"

[adapter]
type = "command"

[runner]
type = "custom"
command = "git-compat"
list = "node tools/flaker-list-git-compat-tests.mjs"
execute = "node tools/flaker-run-git-compat-tests.mjs"

[affected]
resolver = "glob"
config = "tools/flaker-affected-rules.toml"

[quarantine]
auto = true
flaky_rate_threshold = 0.3
min_runs = 5

[flaky]
window_days = 14
detection_threshold = 0.1
55 changes: 55 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ test:
moon test --target wasm -p mizchi/bit/runtime -f storage_runtime_wbtest.mbt
moon test --target native --no-parallelize -j 1
just test-git-compat-allowlist
just test-flaker-affected-rules
just test-flaker-cli-wrapper
just test-flaker-git-compat
just test-js-build

# Update snapshot tests (both js and native)
Expand Down Expand Up @@ -100,6 +103,18 @@ test-js-build: sync-npm-lib-raw sync-npm-bit-cjs bundle-js-lib-minimal bundle-js
test-git-compat-allowlist:
node --test tools/git-compat-allowlist.test.mjs

# Verify flaker-focused git-compat inventory helpers
test-flaker-git-compat:
node --test tools/flaker-git-compat.test.mjs

# Verify flaker git-compat affected mapping config and examples
test-flaker-affected-rules:
node --test tools/flaker-affected-rules.test.mjs

# Verify flaker CLI wrapper guidance for unsupported resolver versions
test-flaker-cli-wrapper:
node --test tools/flaker-cli-wrapper.test.mjs

# Verify JS-exported lib on a pure in-memory host
test-js-lib: build-js-lib
node tools/verify-libgit2-js.mjs
Expand Down Expand Up @@ -363,6 +378,46 @@ compat-random-run:
compat-random-aggregate results_dir="compat-random-results":
bash tools/aggregate-git-compat-random.sh {{results_dir}}

# Focused local git-compat sampling via flaker
flaker-git-compat-sample strategy="weighted" count="25" changed="":
@if ! command -v flaker >/dev/null 2>&1; then \
echo "flaker CLI is required; install @mizchi/flaker first" >&2; \
exit 1; \
fi
@if { [ "{{strategy}}" = "affected" ] || [ "{{strategy}}" = "hybrid" ]; } && [ -z "{{changed}}" ]; then \
echo "changed=... is required when strategy={{strategy}}" >&2; \
exit 1; \
fi
@args="sample --strategy {{strategy}} --count {{count}}"; \
if [ -n "{{changed}}" ]; then \
args="$args --changed {{changed}}"; \
fi; \
node tools/flaker-cli-wrapper.mjs $args

# Focused local git-compat execution via flaker
flaker-git-compat-run strategy="weighted" count="25" changed="": build
@if ! command -v flaker >/dev/null 2>&1; then \
echo "flaker CLI is required; install @mizchi/flaker first" >&2; \
exit 1; \
fi
@if { [ "{{strategy}}" = "affected" ] || [ "{{strategy}}" = "hybrid" ]; } && [ -z "{{changed}}" ]; then \
echo "changed=... is required when strategy={{strategy}}" >&2; \
exit 1; \
fi
@args="run --strategy {{strategy}} --count {{count}}"; \
if [ -n "{{changed}}" ]; then \
args="$args --changed {{changed}}"; \
fi; \
node tools/flaker-cli-wrapper.mjs $args

# Inspect which git-compat suites flaker sees as affected
flaker-git-compat-affected changed:
@if ! command -v flaker >/dev/null 2>&1; then \
echo "flaker CLI is required; install @mizchi/flaker first" >&2; \
exit 1; \
fi
node tools/flaker-cli-wrapper.mjs affected --changed {{changed}}

# Trigger Git Compat Randomized workflow via workflow_dispatch
compat-random-dispatch shards="1" ratio="50" target_shard="0" seed="":
@if ! command -v gh >/dev/null 2>&1; then \
Expand Down
4 changes: 2 additions & 2 deletions moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "mizchi/bit",
"version": "0.39.0",
"version": "0.39.2",
"deps": {
"moonbitlang/async": "0.16.6",
"mizchi/zlib": "0.3.0",
"moonbitlang/x": "0.4.40",
"mizchi/tempfile": "0.1.0",
"mizchi/llm": "0.2.2",
"mizchi/bitflow": "0.3.1",
"mizchi/bitflow": "0.4.0",
"mizchi/x": "0.1.4",
"bobzhang/toml": "0.1.7",
"mizchi/libgit2": "0.1.0"
Expand Down
10 changes: 5 additions & 5 deletions src/apply/apply.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pub fn reverse_patch(patch : String) -> String {
let lines : Array[String] = []
for line_view in patch.split("\n") {
let line = line_view.to_string()
if line.has_prefix("+") && !(line.has_prefix("+++")) {
if line.has_prefix("+") && !line.has_prefix("+++") {
lines.push(
"-" + String::unsafe_substring(line, start=1, end=line.length()),
)
} else if line.has_prefix("-") && !(line.has_prefix("---")) {
} else if line.has_prefix("-") && !line.has_prefix("---") {
lines.push(
"+" + String::unsafe_substring(line, start=1, end=line.length()),
)
Expand Down Expand Up @@ -56,7 +56,7 @@ pub fn parse_patches(patch : String) -> Array[PatchInfo] {
let line = all_lines[i]
// Detect start of a diff (git format or non-git format)
let is_git_diff = line.has_prefix("diff --git ")
let is_nongit_diff = !(is_git_diff) && line.has_prefix("diff ")
let is_nongit_diff = !is_git_diff && line.has_prefix("diff ")
if is_git_diff || is_nongit_diff {
let mut old_name = ""
let mut new_name = ""
Expand Down Expand Up @@ -208,11 +208,11 @@ pub fn parse_patches(patch : String) -> Array[PatchInfo] {
break
}
if hunkline.has_prefix("+") &&
!(hunkline.has_prefix("+++ ")) &&
!hunkline.has_prefix("+++ ") &&
hunkline != "+++" {
additions += 1
} else if hunkline.has_prefix("-") &&
!(hunkline.has_prefix("--- ")) &&
!hunkline.has_prefix("--- ") &&
hunkline != "---" {
deletions += 1
}
Expand Down
Loading
Loading