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
6 changes: 3 additions & 3 deletions modules/bit/cmd/bit/add.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ fn normalize_add_path(path : String) -> String {
while out.length() > 1 && out.has_suffix("/") {
out = String::unsafe_substring(out, start=0, end=out.length() - 1)
}
let sb = StringBuilder::new()
let sb = StringBuilder()
let mut i = 0
while i < out.length() {
let c = out[i].unsafe_to_char()
Expand Down Expand Up @@ -841,10 +841,10 @@ fn add_normalize_input_path(root : String, raw_path : String) -> String {

///|
fn add_repo_relative_cwd(root : String) -> String {
let cwd = match @sys.get_env_var("GIT_SHIM_CWD") {
let cwd = match @env.get_env_var("GIT_SHIM_CWD") {
Some(dir) => dir
None =>
match @sys.get_env_var("GIT_SHIM_PWD") {
match @env.get_env_var("GIT_SHIM_PWD") {
Some(dir) => dir
None =>
match @env.current_dir() {
Expand Down
68 changes: 34 additions & 34 deletions modules/bit/cmd/bit/add_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ async test "add: stages parent-relative path from subdirectory" {
add_test_run_git(root, ["init", "-q"])
fs.write_string(root + "/top/x", "hello\n")

let prev_shim_cwd = @sys.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @sys.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @sys.get_env_var("GIT_DIR")
let prev_work_tree = @sys.get_env_var("GIT_WORK_TREE")
@sys.set_env_var("GIT_SHIM_CWD", root + "/top/sub")
@sys.set_env_var("GIT_SHIM_PWD", root + "/top/sub")
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
let prev_shim_cwd = @env.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @env.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @env.get_env_var("GIT_DIR")
let prev_work_tree = @env.get_env_var("GIT_WORK_TREE")
@env.set_env_var("GIT_SHIM_CWD", root + "/top/sub")
@env.set_env_var("GIT_SHIM_PWD", root + "/top/sub")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
handle_add(["../x"])

let entries = @bitlib.read_index_entries(fs, root + "/.git")
Expand Down Expand Up @@ -165,14 +165,14 @@ async test "add: explicit add is clean for real git diff-files" {
add_test_run_git(root, ["commit", "-q", "-m", "initial"])
fs.write_string(root + "/file", "changed\n")

let prev_shim_cwd = @sys.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @sys.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @sys.get_env_var("GIT_DIR")
let prev_work_tree = @sys.get_env_var("GIT_WORK_TREE")
@sys.set_env_var("GIT_SHIM_CWD", root)
@sys.set_env_var("GIT_SHIM_PWD", root)
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
let prev_shim_cwd = @env.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @env.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @env.get_env_var("GIT_DIR")
let prev_work_tree = @env.get_env_var("GIT_WORK_TREE")
@env.set_env_var("GIT_SHIM_CWD", root)
@env.set_env_var("GIT_SHIM_PWD", root)
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
handle_add(["file"])

let diff = add_test_git_stdout(root, ["diff-files", "--name-only", "file"])
Expand Down Expand Up @@ -201,14 +201,14 @@ async test "add: update from subdirectory is clean for real git diff-files" {
add_test_run_git(root, ["commit", "-q", "-m", "initial"])
fs.write_string(root + "/dir1/sub2", "changed\n")

let prev_shim_cwd = @sys.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @sys.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @sys.get_env_var("GIT_DIR")
let prev_work_tree = @sys.get_env_var("GIT_WORK_TREE")
@sys.set_env_var("GIT_SHIM_CWD", root + "/dir1")
@sys.set_env_var("GIT_SHIM_PWD", root + "/dir1")
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
let prev_shim_cwd = @env.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @env.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @env.get_env_var("GIT_DIR")
let prev_work_tree = @env.get_env_var("GIT_WORK_TREE")
@env.set_env_var("GIT_SHIM_CWD", root + "/dir1")
@env.set_env_var("GIT_SHIM_PWD", root + "/dir1")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
handle_add(["-u", "sub2"])

let diff = add_test_git_stdout(root, [
Expand Down Expand Up @@ -245,14 +245,14 @@ async test "add: update refreshes touched tracked files for real git diff-files"
)
assert_eq(touch_code, 0)

let prev_shim_cwd = @sys.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @sys.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @sys.get_env_var("GIT_DIR")
let prev_work_tree = @sys.get_env_var("GIT_WORK_TREE")
@sys.set_env_var("GIT_SHIM_CWD", root)
@sys.set_env_var("GIT_SHIM_PWD", root)
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
let prev_shim_cwd = @env.get_env_var("GIT_SHIM_CWD")
let prev_shim_pwd = @env.get_env_var("GIT_SHIM_PWD")
let prev_git_dir = @env.get_env_var("GIT_DIR")
let prev_work_tree = @env.get_env_var("GIT_WORK_TREE")
@env.set_env_var("GIT_SHIM_CWD", root)
@env.set_env_var("GIT_SHIM_PWD", root)
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
handle_add(["-u"])

let diff = add_test_git_stdout(root, ["diff-files", "--name-only", "check"])
Expand Down Expand Up @@ -308,7 +308,7 @@ fn add_test_trim_trailing_newline(s : String) -> String {
///|
fn add_test_restore_env(name : String, value : String?) -> Unit {
match value {
Some(v) => @sys.set_env_var(name, v)
None => @sys.unset_env_var(name)
Some(v) => @env.set_env_var(name, v)
None => @env.unset_env_var(name)
}
}
4 changes: 2 additions & 2 deletions modules/bit/cmd/bit/ai.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn build_diff_units_for_ai(diffs : Array[@bitdiff.DiffFile]) -> String {
if diffs.length() == 0 {
return ""
}
let out = StringBuilder::new()
let out = StringBuilder()
for unit in split_diff_units(diffs) {
out.write_string("## Logical unit: " + unit.name + "\n")
for item in unit.diffs {
Expand Down Expand Up @@ -118,7 +118,7 @@ fn split_diff_units(diffs : Array[@bitdiff.DiffFile]) -> Array[AiDiffUnit] {

///|
fn build_single_diff_unit_for_ai(unit : AiDiffUnit) -> String {
let out = StringBuilder::new()
let out = StringBuilder()
out.write_string("## Logical unit: " + unit.name + "\n")
for item in unit.diffs {
out.write_string("### " + item.path + "\n")
Expand Down
6 changes: 3 additions & 3 deletions modules/bit/cmd/bit/am.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ async fn apply_remaining_patches(
}
stage_all_changes(fs, root)
if author.length() > 0 {
@sys.set_env_var("GIT_AUTHOR_NAME", extract_name_str(author))
@sys.set_env_var("GIT_AUTHOR_EMAIL", extract_email_str(author))
@env.set_env_var("GIT_AUTHOR_NAME", extract_name_str(author))
@env.set_env_var("GIT_AUTHOR_EMAIL", extract_email_str(author))
}
if author_date.length() > 0 {
@sys.set_env_var("GIT_AUTHOR_DATE", author_date)
@env.set_env_var("GIT_AUTHOR_DATE", author_date)
}
let commit_author = get_author_string()
let commit_timestamp = get_commit_timestamp()
Expand Down
4 changes: 2 additions & 2 deletions modules/bit/cmd/bit/bench_apply_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn bench_apply_ensure_repo() -> Unit {
}
// Create base files
for i in 0..<100 {
let content = StringBuilder::new()
let content = StringBuilder()
for line in 0..<50 {
content.write_string("line \{line} of file \{i}\n")
}
Expand All @@ -42,7 +42,7 @@ fn bench_apply_ensure_repo() -> Unit {
_ => ()
}
// Generate patch file directly (unified diff format)
let diff_buf = StringBuilder::new()
let diff_buf = StringBuilder()
for i in 0..<20 {
diff_buf.write_string("diff --git a/file_\{i}.txt b/file_\{i}.txt\n")
diff_buf.write_string("--- a/file_\{i}.txt\n")
Expand Down
24 changes: 12 additions & 12 deletions modules/bit/cmd/bit/bench_cat_file_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ test "bench cat-file -t commit (×10)" (b : @bench.T) {
let oids = ensure_catfile_bench_repo()
let oid = oids[0]
let args = ["bit", "-C", bench_catfile_repo, "cat-file", "-t", oid]
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
b.bench(fn() {
bench_stdout_suppress()
for _ in 0..<bench_catfile_repeat {
Expand All @@ -97,9 +97,9 @@ test "bench cat-file -p commit (×10)" (b : @bench.T) {
let oids = ensure_catfile_bench_repo()
let oid = oids[0]
let args = ["bit", "-C", bench_catfile_repo, "cat-file", "-p", oid]
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
b.bench(fn() {
bench_stdout_suppress()
for _ in 0..<bench_catfile_repeat {
Expand All @@ -115,9 +115,9 @@ test "bench cat-file -s commit (×10)" (b : @bench.T) {
let oids = ensure_catfile_bench_repo()
let oid = oids[0]
let args = ["bit", "-C", bench_catfile_repo, "cat-file", "-s", oid]
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
b.bench(fn() {
bench_stdout_suppress()
for _ in 0..<bench_catfile_repeat {
Expand All @@ -133,9 +133,9 @@ test "bench cat-file -e commit (×10)" (b : @bench.T) {
let oids = ensure_catfile_bench_repo()
let oid = oids[0]
let args = ["bit", "-C", bench_catfile_repo, "cat-file", "-e", oid]
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
b.bench(fn() {
bench_stdout_suppress()
for _ in 0..<bench_catfile_repeat {
Expand Down
16 changes: 8 additions & 8 deletions modules/bit/cmd/bit/bench_e2e_clone_fetch_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ fn e2e_cleanup_tree(fs : OsFs, path : String) -> Unit {

///|
fn e2e_reset_git_env() -> Unit {
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@sys.unset_env_var("GIT_SHIM_PWD")
@sys.unset_env_var("GIT_SHIM_EXPLICIT_GIT_DIR")
@sys.unset_env_var("GIT_CONFIG_OVERRIDES")
@sys.unset_env_var("SHIM_REAL_GIT")
@sys.unset_env_var("GIT_SHIM_REAL_GIT")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_SHIM_PWD")
@env.unset_env_var("GIT_SHIM_EXPLICIT_GIT_DIR")
@env.unset_env_var("GIT_CONFIG_OVERRIDES")
@env.unset_env_var("SHIM_REAL_GIT")
@env.unset_env_var("GIT_SHIM_REAL_GIT")
}

///|
Expand Down
2 changes: 1 addition & 1 deletion modules/bit/cmd/bit/bench_grep_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn bench_grep_file_body(
lines_per_file : Int,
hit_interval : Int,
) -> String {
let buf = StringBuilder::new()
let buf = StringBuilder()
for line_idx in 0..<lines_per_file {
buf.write_string(
"line=\{line_idx} file=\{file_idx} payload lorem ipsum dolor sit amet\n",
Expand Down
16 changes: 8 additions & 8 deletions modules/bit/cmd/bit/bench_init_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ fn ensure_bench_dir(path : String) -> Unit {

///|
fn bench_reset_env() -> Unit {
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
}

///|
Expand Down Expand Up @@ -92,7 +92,7 @@ fn ensure_bench_config() -> Unit {
@fs.write_string_to_file(bench_config_path, content) catch {
_ => ()
}
@sys.set_env_var("GIT_CONFIG_GLOBAL", bench_config_path)
@env.set_env_var("GIT_CONFIG_GLOBAL", bench_config_path)
}

///|
Expand Down Expand Up @@ -150,10 +150,10 @@ test "bench init first status startup (-C)" (b : @bench.T) {
_ => ()
}
let args = ["bit", "-C", bench_status_repo_root, "status", "--porcelain"]
@sys.unset_env_var("GIT_DIR")
@sys.unset_env_var("GIT_WORK_TREE")
@sys.unset_env_var("GIT_SHIM_CWD")
@sys.unset_env_var("GIT_CONFIG_OVERRIDES")
@env.unset_env_var("GIT_DIR")
@env.unset_env_var("GIT_WORK_TREE")
@env.unset_env_var("GIT_SHIM_CWD")
@env.unset_env_var("GIT_CONFIG_OVERRIDES")
b.bench(fn() {
bench_stdout_suppress()
for _ in 0..<bench_startup_repeat {
Expand Down
8 changes: 4 additions & 4 deletions modules/bit/cmd/bit/blame.mbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
///|
fn resolve_real_git_for_blame() -> String {
match @sys.get_env_var("SHIM_REAL_GIT") {
match @env.get_env_var("SHIM_REAL_GIT") {
Some(path) =>
if path.length() > 0 {
path
} else {
@sys.get_env_var("GIT_SHIM_REAL_GIT").unwrap_or("/usr/bin/git")
@env.get_env_var("GIT_SHIM_REAL_GIT").unwrap_or("/usr/bin/git")
}
None => @sys.get_env_var("GIT_SHIM_REAL_GIT").unwrap_or("/usr/bin/git")
None => @env.get_env_var("GIT_SHIM_REAL_GIT").unwrap_or("/usr/bin/git")
}
}

Expand Down Expand Up @@ -814,7 +814,7 @@ async fn blame_find_line_origin_with_opts(
///|
fn normalize_whitespace(s : String) -> String {
// Collapse all whitespace to single spaces and trim
let result = StringBuilder::new()
let result = StringBuilder()
let mut in_space = true // Start true to trim leading spaces
for c in s {
if c == ' ' || c == '\t' {
Expand Down
12 changes: 6 additions & 6 deletions modules/bit/cmd/bit/branch.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ fn branch_pad_right(s : String, width : Int) -> String {
if s.length() >= width {
return s
}
let buf = StringBuilder::new()
let buf = StringBuilder()
buf.write_string(s)
for i = s.length(); i < width; i = i + 1 {
buf.write_char(' ')
Expand Down Expand Up @@ -572,7 +572,7 @@ fn branch_resolve_column_mode(

///|
fn branch_term_columns() -> Int {
match @sys.get_env_var("COLUMNS") {
match @env.get_env_var("COLUMNS") {
Some(raw) => {
let parsed = @string.parse_int(raw) catch { _ => 80 }
if parsed > 1 {
Expand Down Expand Up @@ -731,14 +731,14 @@ async fn branch_resolve_start_point(

///|
fn branch_get_committer_identity() -> (String, String, Int64, String) {
let name = match @sys.get_env_var("GIT_COMMITTER_NAME") {
let name = match @env.get_env_var("GIT_COMMITTER_NAME") {
Some(n) => n
None => @sys.get_env_var("USER").unwrap_or("Unknown")
None => @env.get_env_var("USER").unwrap_or("Unknown")
}
let email = match @sys.get_env_var("GIT_COMMITTER_EMAIL") {
let email = match @env.get_env_var("GIT_COMMITTER_EMAIL") {
Some(e) => e
None =>
match @sys.get_env_var("USER") {
match @env.get_env_var("USER") {
Some(u) => u + "@localhost"
None => "unknown@localhost"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/bit/cmd/bit/cat_file.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ async fn handle_cat_file(args : Array[String]) -> Unit raise Error {
let mut pending_chunks : Array[Bytes] = []
let buffer_enabled = batch_buffer && !batch_no_buffer
let suppress_flush_on_exit = match
@sys.get_env_var("GIT_TEST_CAT_FILE_NO_FLUSH_ON_EXIT") {
@env.get_env_var("GIT_TEST_CAT_FILE_NO_FLUSH_ON_EXIT") {
Some(value) => value == "1"
None => false
}
Expand Down
2 changes: 1 addition & 1 deletion modules/bit/cmd/bit/check_ref_format.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn check_ref_format_valid(
///|
fn check_ref_format_normalize(refname : String) -> String {
// Collapse consecutive slashes (shouldn't exist if valid, but just in case)
let result = StringBuilder::new()
let result = StringBuilder()
let chars = refname.to_array()
let mut prev_slash = false
for c in chars {
Expand Down
Loading
Loading