Skip to content

Commit 6a9b7b6

Browse files
jclemclaude
andcommitted
Add mise and lefthook configuration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4736bfa commit 6a9b7b6

File tree

3 files changed

+61
-26
lines changed

3 files changed

+61
-26
lines changed

.config/lefthook.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[[pre-commit.jobs]]
2+
run = "mise fix:format"
3+
glob = "*.rs"
4+
stage_fixed = true
5+
6+
[[pre-commit.jobs]]
7+
run = "mise check"
8+
9+
[[pre-commit.jobs]]
10+
run = "mise test"

.config/mise.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[tools]
2+
lefthook = "2.1.1"
3+
rust = "1.93.1"
4+
5+
[tasks.check]
6+
depends = ["check:*"]
7+
8+
[tasks."check:lint"]
9+
run = "cargo clippy --all-targets"
10+
11+
[tasks."check:format"]
12+
run = "cargo fmt --all --check"
13+
14+
[[tasks.fix.run]]
15+
task = "fix:format"
16+
17+
[[tasks.fix.run]]
18+
task = "fix:lint"
19+
20+
[tasks."fix:lint"]
21+
run = "cargo clippy --fix --all-targets --allow-dirty"
22+
23+
[tasks."fix:format"]
24+
run = "cargo fmt --all"
25+
26+
[tasks.test]
27+
run = "cargo test"

src/main.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,14 @@ fn run() -> Result<(), Box<dyn Error>> {
308308
let client = Client::builder().redirect(redirect_policy).build()?;
309309
let mut target = parse_target_url(url)?;
310310
let parsed_input = parse_input(&cli.inputs)?;
311-
let host_for_session = if let Some(ref socket_path) = target.unix_socket {
312-
sanitize_host_path_component(&socket_path.to_string_lossy())
313-
} else {
314-
target
315-
.url
316-
.host_str()
317-
.map(str::to_string)
318-
.ok_or_else(|| {
311+
let host_for_session =
312+
if let Some(ref socket_path) = target.unix_socket {
313+
sanitize_host_path_component(&socket_path.to_string_lossy())
314+
} else {
315+
target.url.host_str().map(str::to_string).ok_or_else(|| {
319316
io::Error::new(io::ErrorKind::InvalidInput, "URL is missing a host")
320317
})?
321-
};
318+
};
322319
let active_profile = active_profile(cli.profile.as_deref())?;
323320
let loaded_session_headers =
324321
load_session_headers(&host_for_session, cli.no_session, &active_profile)?;
@@ -1287,23 +1284,24 @@ fn send_unix_request(
12871284
.enable_all()
12881285
.build()?;
12891286

1290-
let (version, status, resp_headers, body_bytes) = rt.block_on(async move {
1291-
let stream = tokio::net::UnixStream::connect(&socket_path).await?;
1292-
let io = hyper_util::rt::TokioIo::new(stream);
1293-
let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await?;
1294-
tokio::spawn(async move {
1295-
if let Err(e) = conn.await {
1296-
eprintln!("unix socket connection error: {e}");
1297-
}
1298-
});
1299-
let resp = sender.send_request(http_request).await?;
1300-
let version = resp.version();
1301-
let status = resp.status();
1302-
let headers = resp.headers().clone();
1303-
let body = resp.into_body().collect().await?.to_bytes().to_vec();
1304-
Ok::<_, Box<dyn Error + Send + Sync>>((version, status, headers, body))
1305-
})
1306-
.map_err(|e| -> Box<dyn Error> { e })?;
1287+
let (version, status, resp_headers, body_bytes) = rt
1288+
.block_on(async move {
1289+
let stream = tokio::net::UnixStream::connect(&socket_path).await?;
1290+
let io = hyper_util::rt::TokioIo::new(stream);
1291+
let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await?;
1292+
tokio::spawn(async move {
1293+
if let Err(e) = conn.await {
1294+
eprintln!("unix socket connection error: {e}");
1295+
}
1296+
});
1297+
let resp = sender.send_request(http_request).await?;
1298+
let version = resp.version();
1299+
let status = resp.status();
1300+
let headers = resp.headers().clone();
1301+
let body = resp.into_body().collect().await?.to_bytes().to_vec();
1302+
Ok::<_, Box<dyn Error + Send + Sync>>((version, status, headers, body))
1303+
})
1304+
.map_err(|e| -> Box<dyn Error> { e })?;
13071305

13081306
Ok(Response::Unix {
13091307
version,

0 commit comments

Comments
 (0)