Merge pull request #3603 from Byron/windows-improvements

windows improvements
This commit is contained in:
Josh Junon 2024-04-25 12:23:26 +02:00 committed by GitHub
commit 812b4ea27c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 3 deletions

View File

@ -225,4 +225,4 @@ jobs:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: "cargo check"
run: cargo check --all --bins --examples
run: cargo check --all --bins --examples --features windows

View File

@ -70,6 +70,8 @@ correctness = "deny"
[features]
default = ["custom-protocol", "sentry", "devtools"]
## A forwarding to all crates that have windows-specific adjustments for testing on non-Windows.
windows = ["gitbutler-watcher/windows"]
devtools = ["tauri/devtools"]
# this feature is used used for production builds where `devPath` points to the filesystem

View File

@ -35,6 +35,7 @@ pub fn init(app_handle: &AppHandle) {
.parse()
.unwrap_or(LevelFilter::INFO);
let use_colors_in_logs = cfg!(not(feature = "windows"));
let subscriber = tracing_subscriber::registry()
.with(
// subscriber for https://github.com/tokio-rs/console
@ -49,6 +50,7 @@ pub fn init(app_handle: &AppHandle) {
// subscriber that writes spans to stdout
tracing_subscriber::fmt::layer()
.event_format(format_for_humans.clone())
.with_ansi(use_colors_in_logs)
.with_span_events(FmtSpan::CLOSE)
.with_filter(log_level_filter),
)

View File

@ -4,6 +4,11 @@ version = "0.0.0"
edition = "2021"
publish = false
[features]
default = []
## A trial to see if doing things differently on Windows helps with #3601
windows = []
[lib]
doctest = false

View File

@ -12,7 +12,8 @@ use tracing::Level;
/// The timeout for debouncing file change events.
/// This is used to prevent multiple events from being sent for a single file change.
const DEBOUNCE_TIMEOUT: Duration = Duration::from_millis(100);
const DEBOUNCE_TIMEOUT: Duration =
Duration::from_millis(if cfg!(feature = "windows") { 2000 } else { 100 });
/// This error is required only because `anyhow::Error` isn't implementing `std::error::Error`, and [`spawn()`]
/// needs to wrap it into a `backoff::Error` which also has to implement the `Error` trait.
@ -44,6 +45,10 @@ pub fn spawn(
out: tokio::sync::mpsc::UnboundedSender<InternalEvent>,
) -> Result<()> {
let (notify_tx, notify_rx) = std::sync::mpsc::channel();
tracing::info!(
"Starting filesystem monitor on {worktree_path:?} with debounce of {:02}s",
DEBOUNCE_TIMEOUT.as_secs_f32()
);
let mut debouncer =
new_debouncer(DEBOUNCE_TIMEOUT, None, notify_tx).context("failed to create debouncer")?;

View File

@ -163,7 +163,11 @@ CONFIG_PATH=$(readlink -f "$PWD/../crates/gitbutler-tauri/tauri.conf.$CHANNEL.js
# update the version in the tauri release config
jq '.package.version="'"$VERSION"'"' "$CONFIG_PATH" >"$TMP_DIR/tauri.conf.json"
FEATURES=""
if [ "$OS" = "windows" ]; then
FEATURES="windows"
else
FEATURES=""
fi
# build the app with release config
SENTRY_RELEASE="$VERSION" tauri build \