mirror of
https://github.com/sharkdp/bat
synced 2026-08-10 20:01:45 +00:00
Merge branch 'master' into fix/3697-bat-auto-detect-language-from-stdin
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
NAME="${0##*/}"
|
||||
for i in {1..3}; do
|
||||
echo "hello $NAME $i"
|
||||
done
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/expect -f
|
||||
set timeout 30
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env tclsh
|
||||
puts "Hello from tclsh"
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/wish
|
||||
button .b -text "Click"
|
||||
+480
-5
@@ -305,6 +305,19 @@ fn line_range_multiple() {
|
||||
.stdout("line 1\nline 2\nline 4\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snip_at_terminal_width_one_does_not_panic() {
|
||||
bat()
|
||||
.arg("multiline.txt")
|
||||
.arg("--style=snip")
|
||||
.arg("--color=always")
|
||||
.arg("--terminal-width=1")
|
||||
.arg("--line-range=1:2")
|
||||
.arg("--line-range=4:4")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn line_range_multiple_with_context() {
|
||||
bat()
|
||||
@@ -613,12 +626,18 @@ fn list_themes_to_piped_output() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn list_languages() {
|
||||
bat()
|
||||
.arg("--list-languages")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("Rust").normalize());
|
||||
mocked_pagers::with_mocked_versions_of_more_and_most_in_path(|| {
|
||||
bat()
|
||||
.env("PAGER", mocked_pagers::from("echo pager-output"))
|
||||
.arg("--list-languages")
|
||||
.arg("--paging=never")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("Rust").normalize())
|
||||
.stdout(predicate::str::contains("pager-output").not());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1047,6 +1066,57 @@ fn tabs_4_arg_overrides_env_noconfig() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_width_env_var_is_respected() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("long.txt");
|
||||
std::fs::write(
|
||||
&tmp_path,
|
||||
"0123456789abcdef0123456789abcdef0123456789abcdef\n",
|
||||
)
|
||||
.expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.env("BAT_WIDTH", "20")
|
||||
.arg(&tmp_path)
|
||||
.arg("--paging=never")
|
||||
.arg("--color=never")
|
||||
.arg("--style=numbers")
|
||||
.arg("--decorations=always")
|
||||
.arg("--wrap=character")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(" 1 0123456789abcde\n f0123456789abcd\n ef0123456789abc\n def\n")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_width_arg_overrides_env() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("long.txt");
|
||||
std::fs::write(
|
||||
&tmp_path,
|
||||
"0123456789abcdef0123456789abcdef0123456789abcdef\n",
|
||||
)
|
||||
.expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.env("BAT_WIDTH", "20")
|
||||
.arg(&tmp_path)
|
||||
.arg("--paging=never")
|
||||
.arg("--color=never")
|
||||
.arg("--style=numbers")
|
||||
.arg("--decorations=always")
|
||||
.arg("--wrap=character")
|
||||
.arg("--terminal-width=10")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
" 1 01234\n 56789\n abcde\n f0123\n 45678\n 9abcd\n ef012\n 34567\n 89abc\n def\n",
|
||||
)
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fail_non_existing() {
|
||||
bat().arg("non-existing-file").assert().failure();
|
||||
@@ -1474,6 +1544,7 @@ fn diagnostic_sanity_check() {
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("BAT_PAGER="))
|
||||
.stdout(predicate::str::contains("BAT_WIDTH="))
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
@@ -2093,6 +2164,24 @@ fn header_binary() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn header_zip_file_is_binary() {
|
||||
let tmp_dir = tempdir().expect("can create temporary directory");
|
||||
let tmp_path = tmp_dir.path().join("test.zip");
|
||||
std::fs::write(&tmp_path, b"PK\x03\x04hello").expect("can write temporary file");
|
||||
|
||||
bat()
|
||||
.arg(&tmp_path)
|
||||
.arg("--decorations=always")
|
||||
.arg("--style=header")
|
||||
.arg("-r=0:0")
|
||||
.arg("--file-name=test.zip")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("File: test.zip <BINARY>\n")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn header_full_binary() {
|
||||
bat()
|
||||
@@ -2820,6 +2909,25 @@ fn binary_as_text() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binary_as_text_control_char_width() {
|
||||
// Control characters are displayed as caret notation (e.g. ^@) by the
|
||||
// terminal, occupying 2 columns each. With 20 NUL bytes (40 columns) +
|
||||
// "END" (3 columns) = 43 columns, wrapping at terminal width 40 must
|
||||
// produce 2 lines, not 1. See #3631.
|
||||
bat()
|
||||
.arg("--binary=as-text")
|
||||
.arg("--wrap=character")
|
||||
.arg("--terminal-width=40")
|
||||
.arg("--decorations=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--color=never")
|
||||
.arg("regression_tests/issue_3631.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::function(|s: &str| s.lines().count() == 2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_strip_overstrike_for_plain_text() {
|
||||
// Overstrike is preserved for plain text files (no syntax highlighting)
|
||||
@@ -3881,6 +3989,158 @@ fn strip_ansi_auto_does_not_strip_ansi_when_plain_text_by_option() {
|
||||
assert!(output.contains("\x1B[33mYellow"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_implies_strip_ansi() {
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("\x1B[33mYellow\x1B[m")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("Yellow");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_strips_osc_clipboard_hijack() {
|
||||
// OSC 52 sets the system clipboard. A file containing this would silently
|
||||
// overwrite the user's clipboard if displayed unfiltered.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("safe\x1B]52;c;cm0=\x07payload")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("safepayload");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_strips_osc_8_hyperlink_spoof() {
|
||||
// OSC 8 hyperlinks let displayed text point to an arbitrary URL.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("\x1B]8;;https://evil.example\x07click here\x1B]8;;\x07")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("click here");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_strips_window_title_injection() {
|
||||
// OSC 0/1/2 set the terminal window title.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("hello\x1B]0;evil-title\x07world")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("helloworld");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_strips_8bit_csi() {
|
||||
// 8-bit CSI introducer (U+009B) is the single-codepoint equivalent of ESC [.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("a\u{9B}31mRED\u{9B}0mb")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("aREDb");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_substitutes_bare_cr() {
|
||||
// Bare CR (not part of CRLF) is the line-overwrite forgery vector.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("safe\rEVIL")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("safe\u{FFFD}EVIL");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_preserves_crlf() {
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("line1\r\nline2\r\n")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("line1\r\nline2\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_substitutes_bidi_controls() {
|
||||
// Trojan-Source attack (CVE-2021-42574): U+202E (RLO) reorders display.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("admin\u{202E}check")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("admin\u{FFFD}check");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_substitutes_zero_width() {
|
||||
// Zero-width chars allow invisible content / identifier confusion.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("ad\u{200B}min")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("ad\u{FFFD}min");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_preserves_form_feed_in_source() {
|
||||
// FF (U+000C) is used as a section separator in C source and Emacs Lisp.
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("section1\x0Csection2")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("section1\x0Csection2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sanitize_preserves_unicode_text() {
|
||||
bat()
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("--color=never")
|
||||
.arg("--sanitize=always")
|
||||
.write_stdin("snowman ☃ CJK 漢字 emoji 🦀")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("snowman ☃ CJK 漢字 emoji 🦀");
|
||||
}
|
||||
|
||||
// Tests that style components can be removed with `-component`.
|
||||
#[test]
|
||||
fn style_components_can_be_removed() {
|
||||
@@ -4104,3 +4364,218 @@ fn word_wrap_short_line_no_wrap() {
|
||||
.success()
|
||||
.stdout("Single Line\n");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
fn setup_diff_test_repo() -> tempfile::TempDir {
|
||||
use std::process::Command;
|
||||
|
||||
let dir = tempfile::tempdir().expect("can create temporary directory");
|
||||
let repo = dir.path();
|
||||
|
||||
// Initialize a git repo and commit a file
|
||||
Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git init");
|
||||
|
||||
Command::new("git")
|
||||
.args(["config", "user.email", "test@test.com"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git config email");
|
||||
|
||||
Command::new("git")
|
||||
.args(["config", "user.name", "Test"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git config name");
|
||||
|
||||
std::fs::write(repo.join("test.txt"), "line 1\nline 2\nline 3\n").expect("can write test file");
|
||||
|
||||
Command::new("git")
|
||||
.args(["add", "test.txt"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git add");
|
||||
|
||||
Command::new("git")
|
||||
.args(["commit", "-m", "initial"])
|
||||
.current_dir(repo)
|
||||
.output()
|
||||
.expect("git commit");
|
||||
|
||||
// Modify the file so --diff has something to show
|
||||
std::fs::write(
|
||||
repo.join("test.txt"),
|
||||
"line 1\nline 2 modified\nline 3\nline 4 added\n",
|
||||
)
|
||||
.expect("can write modified test file");
|
||||
|
||||
dir
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn diff_plain_preserves_change_markers() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
// With --diff --plain, output should contain the change marker column
|
||||
// but not other decorations like line numbers or grid
|
||||
let output = bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--diff")
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
let stdout = std::str::from_utf8(&output).expect("valid utf-8");
|
||||
|
||||
// The output should contain the modified and added lines
|
||||
assert!(
|
||||
stdout.contains("line 2 modified"),
|
||||
"diff plain output should contain modified line, got: {stdout}"
|
||||
);
|
||||
assert!(
|
||||
stdout.contains("line 4 added"),
|
||||
"diff plain output should contain added line, got: {stdout}"
|
||||
);
|
||||
|
||||
// Should NOT contain line numbers (a decoration that --plain disables)
|
||||
assert!(
|
||||
!stdout.contains(" 1"),
|
||||
"diff plain output should not contain line numbers, got: {stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn diff_plain_does_not_show_grid_or_header() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
let output = bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--diff")
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("--terminal-width=80")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.get_output()
|
||||
.stdout
|
||||
.clone();
|
||||
|
||||
let stdout = std::str::from_utf8(&output).expect("valid utf-8");
|
||||
|
||||
// Grid lines use box-drawing characters
|
||||
assert!(
|
||||
!stdout.contains('─'),
|
||||
"diff plain output should not contain grid lines, got: {stdout}"
|
||||
);
|
||||
assert!(
|
||||
!stdout.contains('│'),
|
||||
"diff plain output should not contain grid separators, got: {stdout}"
|
||||
);
|
||||
|
||||
// Header shows "File: <filename>"
|
||||
assert!(
|
||||
!stdout.contains("File:"),
|
||||
"diff plain output should not contain file header, got: {stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(feature = "git")]
|
||||
#[test]
|
||||
fn plain_without_diff_still_works() {
|
||||
let repo = setup_diff_test_repo();
|
||||
|
||||
// --plain without --diff should output file content with no decorations at all
|
||||
bat()
|
||||
.current_dir(repo.path())
|
||||
.arg("--plain")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("line 1\nline 2 modified\nline 3\nline 4 added\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_tclsh() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_tclsh")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_wish() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_wish")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tcl_shebang_detection_expect() {
|
||||
bat()
|
||||
.arg("--color=always")
|
||||
.arg("--style=plain")
|
||||
.arg("--decorations=always")
|
||||
.arg("regression_tests/issue_3647_expect")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignored_suffix_enables_first_line_detection() {
|
||||
// A shebang shell script saved with a `.txt` extension is Plain Text by
|
||||
// default (the extension wins). With `--ignored-suffix .txt` the suffix is
|
||||
// stripped before detection, so it falls back to the first line and is
|
||||
// highlighted exactly as if its language were forced to bash. See #2745.
|
||||
let fixture = "regression_tests/issue_2745.txt";
|
||||
let common = ["--color=always", "--decorations=never", "--style=plain"];
|
||||
|
||||
let stdout = |args: &[&str]| -> Vec<u8> {
|
||||
let assert = bat()
|
||||
.args(common)
|
||||
.args(args)
|
||||
.arg(fixture)
|
||||
.assert()
|
||||
.success();
|
||||
assert.get_output().stdout.clone()
|
||||
};
|
||||
|
||||
let forced_bash = stdout(&["--language", "bash"]);
|
||||
let with_ignored_suffix = stdout(&["--ignored-suffix", ".txt"]);
|
||||
let default = stdout(&[]);
|
||||
|
||||
// The fixture really is being highlighted (forcing bash is not a no-op).
|
||||
assert!(
|
||||
forced_bash.windows(2).any(|w| w == b"\x1b["),
|
||||
"forced-bash output should contain ANSI color codes"
|
||||
);
|
||||
// With the ignored suffix, detection matches forced bash highlighting...
|
||||
assert_eq!(with_ignored_suffix, forced_bash);
|
||||
// ...while the default (extension wins) stays plain and differs.
|
||||
assert_ne!(default, forced_bash);
|
||||
}
|
||||
|
||||
+12
-10
@@ -4,6 +4,7 @@ import itertools
|
||||
import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
def generate_snapshots():
|
||||
@@ -19,22 +20,23 @@ def generate_snapshots():
|
||||
|
||||
|
||||
def generate_style_snapshot(style):
|
||||
generate_snapshot(style.replace(",", "_"), "--style={}".format(style))
|
||||
generate_snapshot(style.replace(",", "_"), ["--style={}".format(style)])
|
||||
|
||||
|
||||
def generate_snapshot(name, arguments):
|
||||
command = "cargo run -- --paging=never --color=never --decorations=always "
|
||||
command += "{args} sample.rs > output/{name}.snapshot.txt".format(
|
||||
name=name,
|
||||
args=arguments
|
||||
)
|
||||
def generate_snapshot(name: str, arguments: Iterable[str]):
|
||||
output_file = "output/{name}.snapshot.txt".format(name=name)
|
||||
command = [
|
||||
"cargo", "run", "--", "--paging=never", "--color=never",
|
||||
"--decorations=always", *arguments, "sample.rs"
|
||||
]
|
||||
print("generating snapshot for {}".format(name))
|
||||
subprocess.call(command, shell=True)
|
||||
with open(output_file, "w") as f:
|
||||
subprocess.call(command, stdout=f)
|
||||
|
||||
|
||||
def build_bat():
|
||||
print("building bat")
|
||||
subprocess.call("cargo build", cwd="../..", shell=True)
|
||||
subprocess.call(["cargo", "build"], cwd="../..")
|
||||
|
||||
|
||||
def prepare_output_dir():
|
||||
@@ -49,7 +51,7 @@ def modify_sample_file():
|
||||
|
||||
def undo_sample_file_modification():
|
||||
print("undoing sample.rs modifications")
|
||||
subprocess.call("git checkout -- sample.rs", shell=True)
|
||||
subprocess.call(["git", "checkout", "--", "sample.rs"])
|
||||
|
||||
|
||||
build_bat()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[38;2;248;248;242m([0m[38;2;255;255;255mlogging[0m[38;2;248;248;242m)[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mlog[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moutput[0m[38;2;248;248;242m file /var/log/caddy.log[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;117;113;94m# a comment[0m
|
||||
[38;2;255;255;255mlocalhost:8080[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;255;255;255mexample.com[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mroot[0m[38;2;248;248;242m * /var/www/site[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mfile_server[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mreverse_proxy[0m[38;2;248;248;242m /.well-known/matrix/* localhost:8008[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mheader_up[0m[38;2;248;248;242m Host [0m[38;2;190;132;255m{upstream_hostport}[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mimport[0m[38;2;248;248;242m logging[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;255;255;255mwww.example.com[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mredir[0m[38;2;248;248;242m https://example.com[0m[38;2;190;132;255m{uri}[0m[38;2;248;248;242m permanent[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mimport[0m[38;2;248;248;242m logging[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;255;255;255mstatus.example.com[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mreverse_proxy[0m[38;2;248;248;242m localhost:3002[0m
|
||||
[38;2;248;248;242m [0m[38;2;102;217;239mimport[0m[38;2;248;248;242m logging[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
+52
-52
@@ -1,85 +1,85 @@
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m kotlin.math.*[0m
|
||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242mkotlin[0m[38;2;248;248;242m.[0m[38;2;248;248;242mmath[0m[38;2;248;248;242m.[0m[38;2;249;38;114m*[0m
|
||||
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mExample[0m[38;2;248;248;242m([0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mname[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mnumbers[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mList[0m[38;2;248;248;242m<[0m[3;38;2;102;217;239mInt[0m[38;2;248;248;242m?>[0m
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mExample[0m[38;2;248;248;242m([0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mname[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m,[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mnumbers[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mList[0m[38;2;248;248;242m<[0m[3;38;2;166;226;46mInt[0m[38;2;249;38;114m?[0m[38;2;248;248;242m>[0m
|
||||
[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46minterface[0m[38;2;248;248;242m [0m[38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;166;226;46mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mBoolean[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46minterface[0m[38;2;248;248;242m [0m[38;2;248;248;242mJokeInterface[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBoolean[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m
|
||||
[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mAbstractJoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255mfalse[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mJoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mBoolean[0m[38;2;248;248;242m {[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mJoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mAbstractJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46misFunny[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mBoolean[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;190;132;255mtrue[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcontent of joke here, haha[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mcontent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mcontent of joke here, haha[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;249;38;114m:[0m[38;2;248;248;242m Joke) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mby[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mjoke[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mnumber[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mLong[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m123L[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJoke[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mJokeInterface[0m[38;2;248;248;242m [0m[38;2;249;38;114mby[0m[38;2;248;248;242m [0m[38;2;255;255;255mjoke[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mnumber[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mLong[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m123L[0m
|
||||
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mcompanion [0m[38;2;249;38;114mobject[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mconst[0m[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46msomeConstant[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msome constant text[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mcompanion[0m[38;2;248;248;242m [0m[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mconst[0m[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255msomeConstant[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msome constant text[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;166;226;46mSomeSingleton[0m
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mSomeSingleton[0m
|
||||
|
||||
[38;2;249;38;114msealed[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mShape[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m
|
||||
[38;2;249;38;114msealed[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mShape[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mabstract[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mSquare[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31msideLength[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m sideLength[0m[38;2;249;38;114m.[0m[38;2;248;248;242mpow([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m
|
||||
[38;2;249;38;114mdata[0m[38;2;248;248;242m [0m[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mSquare[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31msideLength[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255msideLength[0m[38;2;248;248;242m.[0m[38;2;248;248;242mpow[0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[38;2;166;226;46mPoint[0m[38;2;248;248;242m [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;190;132;255m0[0m
|
||||
[38;2;249;38;114mobject[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mPoint[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m.0[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mCircle[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mradius[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m) [0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;4;38;2;166;226;46mShape[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m()[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mDouble[0m[38;2;248;248;242m {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;190;132;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m radius [0m[38;2;249;38;114m*[0m[38;2;248;248;242m radius[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;249;38;114mclass[0m[38;2;248;248;242m [0m[4;38;2;102;217;239mCircle[0m[38;2;248;248;242m([0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mradius[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mShape[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114moverride[0m[38;2;248;248;242m [0m[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46marea[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mDouble[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;255;255;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;255;255;255mradius[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;255;255;255mradius[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m String.[0m[38;2;166;226;46mextensionMethod[0m[38;2;248;248;242m() [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mtest[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mString[0m[38;2;248;248;242m.[0m[38;2;166;226;46mextensionMethod[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mtest[0m[38;2;230;219;116m"[0m
|
||||
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mmain[0m[38;2;248;248;242m() {[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m
|
||||
[38;2;249;38;114mfun[0m[38;2;248;248;242m [0m[38;2;166;226;46mmain[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m
|
||||
[38;2;230;219;116m multiline[0m
|
||||
[38;2;230;219;116m string[0m
|
||||
[38;2;230;219;116m [0m
|
||||
[38;2;230;219;116m some numbers: 123123 42[0m
|
||||
[38;2;230;219;116m [0m[38;2;230;219;116m"""[0m[38;2;249;38;114m.[0m[38;2;248;248;242mtrimIndent()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;166;226;46mexample[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m Example(name [0m[38;2;249;38;114m=[0m[38;2;248;248;242m name, numbers [0m[38;2;249;38;114m=[0m[38;2;248;248;242m listOf([0m[38;2;190;132;255m512[0m[38;2;248;248;242m, [0m[38;2;190;132;255m42[0m[38;2;248;248;242m, [0m[38;2;190;132;255mnull[0m[38;2;248;248;242m, [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m))[0m
|
||||
[38;2;230;219;116m [0m[38;2;230;219;116m"""[0m[38;2;248;248;242m.[0m[38;2;248;248;242mtrimIndent[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mval[0m[38;2;248;248;242m [0m[38;2;255;255;255mexample[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mExample[0m[38;2;248;248;242m([0m[38;2;255;255;255mname[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mname[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255mnumbers[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242mlistOf[0m[38;2;248;248;242m([0m[38;2;190;132;255m512[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m42[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255mnull[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;248;248;242m example[0m[38;2;249;38;114m.[0m[38;2;248;248;242mnumbers[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mfilterNotNull()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEach { println(it) }[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255mexample[0m[38;2;248;248;242m.[0m[38;2;255;255;255mnumbers[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mfilterNotNull[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEach[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;255;255;255mit[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m setOf(Joke(), DelegatedJoke(Joke())[0m[38;2;249;38;114m.[0m[38;2;248;248;242mjoke)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mfilter(JokeInterface[0m[38;2;249;38;114m::[0m[38;2;248;248;242misFunny)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mmap(AbstractJoke[0m[38;2;249;38;114m::[0m[38;2;248;248;242mcontent)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEachIndexed { index[0m[38;2;249;38;114m:[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mInt[0m[38;2;248;248;242m, joke [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[38;2;230;219;116mI heard a funny joke(#[0m[3;38;2;253;151;31m${index + 1}[0m[38;2;230;219;116m): [0m[3;38;2;253;151;31m$joke[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242msetOf[0m[38;2;248;248;242m([0m[38;2;248;248;242mJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mDelegatedJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242mJoke[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m[38;2;248;248;242m.[0m[38;2;255;255;255mjoke[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mfilter[0m[38;2;248;248;242m([0m[38;2;255;255;255mJokeInterface[0m[38;2;248;248;242m::[0m[38;2;248;248;242misFunny[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mmap[0m[38;2;248;248;242m([0m[38;2;255;255;255mAbstractJoke[0m[38;2;248;248;242m::[0m[38;2;248;248;242mcontent[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEachIndexed[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mindex[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[3;38;2;166;226;46mInt[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mjoke[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mI heard a funny joke(#[0m[38;2;248;248;242m${[0m[38;2;255;255;255mindex[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m}[0m[38;2;230;219;116m): [0m[38;2;255;255;255m$joke[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m listOf(Square([0m[38;2;190;132;255m12.3[0m[38;2;248;248;242m), Point, Circle([0m[38;2;190;132;255m5.2[0m[38;2;248;248;242m))[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242massociateWith(Shape[0m[38;2;249;38;114m::[0m[38;2;248;248;242marea)[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mtoList()[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242msortedBy { it[0m[38;2;249;38;114m.[0m[38;2;248;248;242msecond }[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114m.[0m[38;2;248;248;242mforEach {[0m
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[3;38;2;253;151;31m${it.first}[0m[38;2;230;219;116m: [0m[3;38;2;253;151;31m${it.second}[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mlistOf[0m[38;2;248;248;242m([0m[38;2;248;248;242mSquare[0m[38;2;248;248;242m([0m[38;2;190;132;255m12.3[0m[38;2;248;248;242m)[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255mPoint[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mCircle[0m[38;2;248;248;242m([0m[38;2;190;132;255m5.2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242massociateWith[0m[38;2;248;248;242m([0m[38;2;255;255;255mShape[0m[38;2;248;248;242m::[0m[38;2;248;248;242marea[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mtoList[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242msortedBy[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255msecond[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m.[0m[38;2;248;248;242mforEach[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;248;248;242m${[0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255mfirst[0m[38;2;248;248;242m}[0m[38;2;230;219;116m: [0m[38;2;248;248;242m${[0m[38;2;255;255;255mit[0m[38;2;248;248;242m.[0m[38;2;255;255;255msecond[0m[38;2;248;248;242m}[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m println([0m[38;2;230;219;116m"[0m[38;2;230;219;116msome string[0m[38;2;230;219;116m"[0m[38;2;249;38;114m.[0m[38;2;248;248;242mextensionMethod())[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mprintln[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116msome string[0m[38;2;230;219;116m"[0m[38;2;248;248;242m.[0m[38;2;248;248;242mextensionMethod[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m
|
||||
|
||||
[38;2;248;248;242m require(SomeSingleton[0m[38;2;249;38;114m::[0m[38;2;248;248;242mclass[0m[38;2;249;38;114m.[0m[38;2;248;248;242msimpleName [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSomeSingletonName[0m[38;2;230;219;116m"[0m[38;2;248;248;242m) { [0m[38;2;230;219;116m"[0m[38;2;230;219;116msomething does not seem right...[0m[38;2;230;219;116m"[0m[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m [0m[38;2;248;248;242mrequire[0m[38;2;248;248;242m([0m[38;2;255;255;255mSomeSingleton[0m[38;2;248;248;242m::[0m[38;2;249;38;114mclass[0m[38;2;248;248;242m.[0m[38;2;255;255;255msimpleName[0m[38;2;248;248;242m [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSomeSingletonName[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msomething does not seem right...[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/expect -f[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Expect script detected via expect shebang[0m
|
||||
[38;2;249;38;114mset[0m[38;2;248;248;242m timeout [0m[38;2;190;132;255m30[0m
|
||||
[38;2;248;248;242mspawn[0m[38;2;248;248;242m ssh user@host[0m
|
||||
[38;2;248;248;242mexpect[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpassword:[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242msend[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116msecret[0m[38;2;190;132;255m\r[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242mexpect[0m[38;2;248;248;242m [0m[38;2;249;38;114meof[0m
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/env tclsh[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Tcl script detected via tclsh shebang[0m
|
||||
[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello from tclsh[0m[38;2;230;219;116m"[0m
|
||||
[38;2;249;38;114mset[0m[38;2;248;248;242m x [0m[38;2;190;132;255m42[0m
|
||||
[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;255;255;255m$[0m[38;2;255;255;255mx[0m[38;2;248;248;242m [0m[38;2;249;38;114m>[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
||||
[38;2;248;248;242m [0m[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpositive[0m[38;2;230;219;116m"[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
@@ -0,0 +1,5 @@
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m!/usr/bin/wish[0m
|
||||
[38;2;117;113;94m#[0m[38;2;117;113;94m Tk script detected via wish shebang[0m
|
||||
[38;2;249;38;114mpackage[0m[38;2;248;248;242m require Tk[0m
|
||||
[38;2;248;248;242mbutton[0m[38;2;248;248;242m .b [0m[38;2;249;38;114m-[0m[38;2;248;248;242mtext [0m[38;2;230;219;116m"[0m[38;2;230;219;116mClick[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mcommand [0m[38;2;248;248;242m{[0m[38;2;249;38;114mputs[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mclicked[0m[38;2;230;219;116m"[0m[38;2;248;248;242m}[0m
|
||||
[38;2;248;248;242mpack[0m[38;2;248;248;242m .b[0m
|
||||
@@ -0,0 +1,7 @@
|
||||
[38;2;255;255;255m<[0m[38;2;249;38;114mSolution[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFolder[0m[38;2;248;248;242m [0m[38;2;166;226;46mName[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116m/Build/[0m[38;2;230;219;116m"[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFile[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mDirectory.Build.props[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mFile[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mprojectname.targets[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;249;38;114mFolder[0m[38;2;255;255;255m>[0m
|
||||
[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;249;38;114mProject[0m[38;2;248;248;242m [0m[38;2;166;226;46mPath[0m[38;2;248;248;242m=[0m[38;2;230;219;116m"[0m[38;2;230;219;116mconsole.csproj[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m
|
||||
[38;2;255;255;255m</[0m[38;2;249;38;114mSolution[0m[38;2;255;255;255m>[0m
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
(logging) {
|
||||
log {
|
||||
output file /var/log/caddy.log
|
||||
}
|
||||
}
|
||||
|
||||
# a comment
|
||||
localhost:8080, example.com {
|
||||
root * /var/www/site
|
||||
file_server
|
||||
reverse_proxy /.well-known/matrix/* localhost:8008 {
|
||||
header_up Host {upstream_hostport}
|
||||
}
|
||||
import logging
|
||||
}
|
||||
|
||||
www.example.com {
|
||||
redir https://example.com{uri} permanent
|
||||
import logging
|
||||
}
|
||||
|
||||
status.example.com {
|
||||
reverse_proxy localhost:3002
|
||||
import logging
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/expect -f
|
||||
# Expect script detected via expect shebang
|
||||
set timeout 30
|
||||
spawn ssh user@host
|
||||
expect "password:"
|
||||
send "secret\r"
|
||||
expect eof
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env tclsh
|
||||
# Tcl script detected via tclsh shebang
|
||||
puts "Hello from tclsh"
|
||||
set x 42
|
||||
if {$x > 0} {
|
||||
puts "positive"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/wish
|
||||
# Tk script detected via wish shebang
|
||||
package require Tk
|
||||
button .b -text "Click" -command {puts "clicked"}
|
||||
pack .b
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<Solution>
|
||||
<Folder Name="/Build/">
|
||||
<File Path="Directory.Build.props" />
|
||||
<File Path="projectname.targets" />
|
||||
</Folder>
|
||||
<Project Path="console.csproj" />
|
||||
</Solution>
|
||||
+37
-28
@@ -1,15 +1,17 @@
|
||||
use gix::actor::SignatureRef;
|
||||
use gix::bstr::BString;
|
||||
use gix::bstr::ByteSlice;
|
||||
use gix::date::time::Format;
|
||||
use gix::date::Time;
|
||||
use gix::objs::tree;
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use tempfile::TempDir;
|
||||
|
||||
use git2::build::CheckoutBuilder;
|
||||
use git2::Repository;
|
||||
use git2::Signature;
|
||||
|
||||
pub struct BatTester {
|
||||
/// Temporary working directory
|
||||
temp_dir: TempDir,
|
||||
@@ -59,35 +61,42 @@ impl Default for BatTester {
|
||||
}
|
||||
}
|
||||
|
||||
fn create_sample_directory() -> Result<TempDir, git2::Error> {
|
||||
fn create_sample_directory() -> Result<TempDir, Box<dyn std::error::Error>> {
|
||||
// Create temp directory and initialize repository
|
||||
let temp_dir = TempDir::new().expect("Temp directory");
|
||||
let repo = Repository::init(&temp_dir)?;
|
||||
let repo = gix::init(&temp_dir)?;
|
||||
let mut tree = gix::objs::Tree::empty();
|
||||
|
||||
// Copy over `sample.rs`
|
||||
let sample_path = temp_dir.path().join("sample.rs");
|
||||
println!("{sample_path:?}");
|
||||
fs::copy("tests/snapshots/sample.rs", &sample_path).expect("successful copy");
|
||||
// Create sample.rs from snapshot file
|
||||
let blob_id = repo.write_blob_stream(File::open("tests/snapshots/sample.rs")?)?;
|
||||
let entry = tree::Entry {
|
||||
mode: tree::EntryMode::from(tree::EntryKind::Blob),
|
||||
oid: blob_id.object()?.id,
|
||||
filename: BString::from("sample.rs"),
|
||||
};
|
||||
tree.entries.push(entry);
|
||||
let tree_id = repo.write_object(tree)?;
|
||||
|
||||
// Commit
|
||||
let mut index = repo.index()?;
|
||||
index.add_path(Path::new("sample.rs"))?;
|
||||
|
||||
let oid = index.write_tree()?;
|
||||
let signature = Signature::now("bat test runner", "bat@test.runner")?;
|
||||
let tree = repo.find_tree(oid)?;
|
||||
let _ = repo.commit(
|
||||
Some("HEAD"), // point HEAD to our new commit
|
||||
&signature, // author
|
||||
&signature, // committer
|
||||
let author = SignatureRef {
|
||||
name: "test".as_bytes().as_bstr(),
|
||||
email: "test@test.test".as_bytes().as_bstr(),
|
||||
time: &Time::now_local_or_utc().format_or_unix(Format::Raw),
|
||||
};
|
||||
let commit_id = repo.commit_as(
|
||||
author,
|
||||
author,
|
||||
"HEAD",
|
||||
"initial commit",
|
||||
&tree,
|
||||
&[],
|
||||
);
|
||||
let mut opts = CheckoutBuilder::new();
|
||||
repo.checkout_head(Some(opts.force()))?;
|
||||
tree_id,
|
||||
gix::commit::NO_PARENT_IDS,
|
||||
)?;
|
||||
assert_eq!(commit_id, repo.head_id()?);
|
||||
|
||||
fs::copy("tests/snapshots/sample.modified.rs", &sample_path).expect("successful copy");
|
||||
fs::copy(
|
||||
"tests/snapshots/sample.modified.rs",
|
||||
temp_dir.path().join("sample.rs"),
|
||||
)
|
||||
.expect("successful copy");
|
||||
|
||||
Ok(temp_dir)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user