Skip to content

Commit

Permalink
ci: fix pre-commit format for Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Martichou committed Feb 25, 2024
1 parent 6452132 commit 8ae9e68
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
- repo: local
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: fmt_rust
name: fmt_rust
entry: bash -c 'rustfmt core_lib/**.rs frontend/src-tauri/**.rs'
language: system
- id: rust-format
name: Rust Format
entry: ./rs_fmt.sh
language: script
stages: [commit]
2 changes: 1 addition & 1 deletion core_lib/bindings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export * from "./ChannelMessage"
export * from "./TransferMetadata"
export * from "./ChannelAction"
export * from "./RemoteDeviceInfo"
export * from "./State"
export * from "./State"
14 changes: 7 additions & 7 deletions frontend/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ async fn main() -> Result<(), anyhow::Error> {

fn rs2js<R: tauri::Runtime>(message: ChannelMessage, manager: &impl Manager<R>) {
if message.direction == ChannelDirection::FrontToLib {
return;
}
return;
}

info!("rs2js: {:?}", &message);
info!("rs2js: {:?}", &message);
manager.emit_all("rs2js", &message).unwrap();
}

#[tauri::command]
fn js2rs(message: ChannelMessage, state: tauri::State<'_, AppState>) -> Result<(), String> {
info!("js2rs: {:?}", &message);

match state.sender.send(message) {
Ok(_) => Ok(()),
Err(e) => return Err(format!("Coudln't perform: {}", e))
}
match state.sender.send(message) {
Ok(_) => Ok(()),
Err(e) => return Err(format!("Coudln't perform: {}", e)),
}
}
5 changes: 5 additions & 0 deletions rs_fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

for dir in core_lib frontend/src-tauri; do
find "$dir" -name '*.rs' -not -path "*/target/*" -exec rustfmt {} +
done
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edition = "2018"

0 comments on commit 8ae9e68

Please sign in to comment.