Skip to content

Commit 603652e

Browse files
committed
chore: align 'app' and 'lib' crates imports.
This is done one-time (for now) using a nightly feature of cargo-fmt as defined in `rustfmt-nightly.toml.` It's planned to make this the default so imports will always be sorted. For now it can be run manually with: cargo +nightly fmt -- --config-path rustfmt-nightly.toml or pnpm rustfmt
1 parent 47e5bad commit 603652e

File tree

111 files changed

+324
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+324
-366
lines changed

crates/gitbutler-app/src/analytics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::{fmt, str, sync::Arc};
22

3-
use tauri::AppHandle;
4-
53
use gitbutler::{projects::ProjectId, users::User};
4+
use tauri::AppHandle;
65

76
mod posthog;
87

crates/gitbutler-app/src/analytics/posthog/retry.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ impl<T: super::Client + Sync> super::Client for Client<T> {
4040

4141
#[cfg(test)]
4242
mod tests {
43-
use super::*;
44-
4543
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
4644

47-
use super::super::Client;
45+
use super::{super::Client, *};
4846

4947
#[derive(Clone)]
5048
struct MockClient {

crates/gitbutler-app/src/app.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::{collections::HashMap, path};
22

33
use anyhow::{Context, Result};
4-
5-
use crate::watcher;
64
use gitbutler::{
75
askpass::AskpassBroker,
86
gb_repository, git,
@@ -14,6 +12,8 @@ use gitbutler::{
1412
virtual_branches::BranchId,
1513
};
1614

15+
use crate::watcher;
16+
1717
#[derive(Clone)]
1818
pub struct App {
1919
local_data_dir: path::PathBuf,

crates/gitbutler-app/src/commands.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use std::{collections::HashMap, path};
22

33
use anyhow::Context;
4-
use tauri::Manager;
5-
use tracing::instrument;
6-
7-
use crate::{app, watcher};
84
use gitbutler::{
95
error::{Code, Error},
106
gb_repository, git, project_repository, projects, reader,
117
sessions::SessionId,
128
users,
139
};
10+
use tauri::Manager;
11+
use tracing::instrument;
12+
13+
use crate::{app, watcher};
1414

1515
impl From<app::Error> for Error {
1616
fn from(value: app::Error) -> Self {

crates/gitbutler-app/src/deltas.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
pub mod commands {
22
use std::collections::HashMap;
33

4+
use gitbutler::deltas::{controller::ListError, Controller, Delta};
45
use tauri::{AppHandle, Manager};
56
use tracing::instrument;
67

78
use crate::error::{Code, Error};
89

9-
use gitbutler::deltas::{controller::ListError, Controller, Delta};
10-
1110
impl From<ListError> for Error {
1211
fn from(value: ListError) -> Self {
1312
match value {

crates/gitbutler-app/src/error.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ pub(crate) mod gb {
99

1010
#[cfg(feature = "error-context")]
1111
mod error_context {
12-
use super::{ErrorKind, Result, WithContext};
13-
use backtrace::Backtrace;
1412
use std::collections::BTreeMap;
1513

14+
use backtrace::Backtrace;
15+
16+
use super::{ErrorKind, Result, WithContext};
17+
1618
#[derive(Debug)]
1719
pub struct Context {
1820
pub backtrace: Backtrace,

crates/gitbutler-app/src/error/sentry.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use crate::error::gb::{ErrorCode, ErrorContext};
1+
use std::collections::BTreeMap;
2+
23
use sentry::{
34
protocol::{value::Map, Event, Exception, Value},
45
types::Uuid,
56
};
6-
use std::collections::BTreeMap;
7+
8+
use crate::error::gb::{ErrorCode, ErrorContext};
79

810
pub trait SentrySender {
911
fn send_to_sentry(self) -> Uuid;

crates/gitbutler-app/src/events.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use anyhow::{Context, Result};
2-
use tauri::{AppHandle, Manager};
3-
42
use gitbutler::{
53
deltas,
64
projects::ProjectId,
75
reader,
86
sessions::{self, SessionId},
97
virtual_branches,
108
};
9+
use tauri::{AppHandle, Manager};
1110

1211
#[derive(Clone)]
1312
pub struct Sender {

crates/gitbutler-app/src/keys.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
pub mod commands {
2+
use gitbutler::keys::{controller, PublicKey};
23
use tauri::Manager;
34
use tracing::instrument;
45

56
use crate::error::Error;
67

7-
use gitbutler::keys::{controller, PublicKey};
8-
98
impl From<controller::GetOrCreateError> for Error {
109
fn from(value: controller::GetOrCreateError) -> Self {
1110
match value {

crates/gitbutler-app/src/main.rs

+7-24
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,17 @@
1313
clippy::too_many_lines
1414
)]
1515

16-
use gitbutler::assets;
17-
use gitbutler::database;
18-
use gitbutler::git;
19-
use gitbutler::storage;
20-
#[cfg(target_os = "windows")]
21-
use gitbutler::windows;
22-
use gitbutler_app::analytics;
23-
use gitbutler_app::app;
24-
use gitbutler_app::askpass;
25-
use gitbutler_app::commands;
26-
use gitbutler_app::deltas;
27-
use gitbutler_app::github;
28-
use gitbutler_app::keys;
29-
use gitbutler_app::logs;
30-
use gitbutler_app::menu;
31-
use gitbutler_app::projects;
32-
use gitbutler_app::sentry;
33-
use gitbutler_app::sessions;
34-
use gitbutler_app::users;
35-
use gitbutler_app::virtual_branches;
36-
use gitbutler_app::watcher;
37-
use gitbutler_app::zip;
38-
3916
use std::path::PathBuf;
4017

4118
use anyhow::Context;
19+
#[cfg(target_os = "windows")]
20+
use gitbutler::windows;
21+
use gitbutler::{assets, database, git, storage};
22+
use gitbutler_app::{
23+
analytics, app, askpass, commands, deltas, github, keys, logs, menu, projects, sentry,
24+
sessions, users, virtual_branches, watcher, zip,
25+
};
4226
use tauri::{generate_context, Manager, Wry};
43-
4427
use tauri_plugin_log::LogTarget;
4528
use tauri_plugin_store::{with_store, JsonValue, StoreCollection};
4629

crates/gitbutler-app/src/projects.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
pub mod commands {
22
use std::path;
33

4-
use tauri::Manager;
5-
use tracing::instrument;
6-
7-
use crate::error::{Code, Error};
8-
94
use gitbutler::projects::{
105
self,
116
controller::{self, Controller},
127
};
8+
use tauri::Manager;
9+
use tracing::instrument;
10+
11+
use crate::error::{Code, Error};
1312

1413
impl From<controller::UpdateError> for Error {
1514
fn from(value: controller::UpdateError) -> Self {

crates/gitbutler-app/src/sentry.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::sync::Arc;
22

3+
use gitbutler::users;
34
use governor::{
45
clock::QuantaClock,
56
state::{InMemoryState, NotKeyed},
@@ -12,8 +13,6 @@ use sentry_tracing::SentryLayer;
1213
use tracing::Subscriber;
1314
use tracing_subscriber::registry::LookupSpan;
1415

15-
use gitbutler::users;
16-
1716
static SENTRY_QUOTA: Quota = Quota::per_second(nonzero!(1_u32)); // 1 per second at most.
1817
static SENTRY_LIMIT: OnceCell<RateLimiter<NotKeyed, InMemoryState, QuantaClock>> = OnceCell::new();
1918

crates/gitbutler-app/src/sessions.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
pub mod commands {
2+
use gitbutler::sessions::{controller::ListError, Controller, Session};
23
use tauri::{AppHandle, Manager};
34
use tracing::instrument;
45

56
use crate::error::{Code, Error};
67

7-
use gitbutler::sessions::{
8-
Session,
9-
{controller::ListError, Controller},
10-
};
11-
128
impl From<ListError> for Error {
139
fn from(value: ListError) -> Self {
1410
match value {

crates/gitbutler-app/src/users.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
pub mod commands {
2+
use gitbutler::{
3+
assets,
4+
users::{
5+
controller::{self, Controller, GetError},
6+
User,
7+
},
8+
};
29
use tauri::{AppHandle, Manager};
310
use tracing::instrument;
411

512
use crate::{error::Error, sentry};
613

7-
use gitbutler::{
8-
assets,
9-
users::controller::{self, Controller, GetError},
10-
users::User,
11-
};
12-
1314
impl From<GetError> for Error {
1415
fn from(value: GetError) -> Self {
1516
match value {

crates/gitbutler-app/src/virtual_branches.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
pub mod commands {
22
use anyhow::Context;
3+
use gitbutler::{
4+
askpass::AskpassBroker,
5+
assets,
6+
error::{Code, Error},
7+
git, projects,
8+
projects::ProjectId,
9+
virtual_branches::{
10+
branch::{self, BranchId, BranchOwnershipClaims},
11+
controller::{Controller, ControllerError},
12+
BaseBranch, RemoteBranch, RemoteBranchData, RemoteBranchFile, VirtualBranches,
13+
},
14+
};
315
use tauri::{AppHandle, Manager};
416
use tracing::instrument;
517

6-
use gitbutler::error::{Code, Error};
7-
818
use crate::watcher;
9-
use gitbutler::askpass::AskpassBroker;
10-
use gitbutler::virtual_branches::{RemoteBranch, RemoteBranchData};
11-
use gitbutler::{
12-
assets, git, projects,
13-
projects::ProjectId,
14-
virtual_branches::branch::{self, BranchId, BranchOwnershipClaims},
15-
virtual_branches::controller::{Controller, ControllerError},
16-
virtual_branches::BaseBranch,
17-
virtual_branches::{RemoteBranchFile, VirtualBranches},
18-
};
1919

2020
fn into_error<E: Into<Error>>(value: ControllerError<E>) -> Error {
2121
match value {

crates/gitbutler-app/src/watcher.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pub mod handlers;
44

55
use std::{collections::HashMap, path, sync::Arc, time};
66

7-
pub use events::Event;
8-
97
use anyhow::{Context, Result};
8+
pub use events::Event;
9+
use gitbutler::projects::{self, Project, ProjectId};
1010
use tauri::AppHandle;
1111
use tokio::{
1212
sync::{
@@ -17,8 +17,6 @@ use tokio::{
1717
};
1818
use tokio_util::sync::CancellationToken;
1919

20-
use gitbutler::projects::{self, Project, ProjectId};
21-
2220
#[derive(Clone)]
2321
pub struct Watchers {
2422
app_handle: AppHandle,

crates/gitbutler-app/src/watcher/dispatchers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ mod file_change;
33
use std::path;
44

55
use anyhow::{Context, Result};
6+
use gitbutler::projects::ProjectId;
67
use tokio::{
78
select,
89
sync::mpsc::{channel, Receiver},
910
task,
1011
};
1112
use tokio_util::sync::CancellationToken;
1213

13-
use gitbutler::projects::ProjectId;
14-
1514
use super::events;
1615

1716
#[derive(Clone)]

crates/gitbutler-app/src/watcher/dispatchers/file_change.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{
66

77
use anyhow::{Context, Result};
88
use futures::executor::block_on;
9+
use gitbutler::{git, projects::ProjectId};
910
use notify::{RecommendedWatcher, Watcher};
1011
use notify_debouncer_full::{new_debouncer, Debouncer, FileIdMap};
1112
use tokio::{
@@ -14,7 +15,6 @@ use tokio::{
1415
};
1516

1617
use crate::watcher::events;
17-
use gitbutler::{git, projects::ProjectId};
1818

1919
#[derive(Debug, Clone)]
2020
pub struct Dispatcher {

crates/gitbutler-app/src/watcher/handlers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ use anyhow::{Context, Result};
1515
use tauri::{AppHandle, Manager};
1616
use tracing::instrument;
1717

18-
use crate::events as app_events;
19-
2018
use super::events;
19+
use crate::events as app_events;
2120

2221
#[derive(Clone)]
2322
pub struct Handler {

crates/gitbutler-app/src/watcher/handlers/analytics_handler.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use anyhow::{Context, Result};
2-
use tauri::{AppHandle, Manager};
3-
4-
use crate::analytics;
52
use gitbutler::users;
3+
use tauri::{AppHandle, Manager};
64

75
use super::events;
6+
use crate::analytics;
87

98
#[derive(Clone)]
109
pub struct Handler {

crates/gitbutler-app/src/watcher/handlers/calculate_deltas_handler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use std::{path, vec};
22

33
use anyhow::{Context, Result};
4-
use tauri::{AppHandle, Manager};
5-
64
use gitbutler::{
75
deltas, gb_repository, project_repository,
86
projects::{self, ProjectId},
97
reader, sessions, users,
108
};
9+
use tauri::{AppHandle, Manager};
1110

1211
use super::events;
1312

0 commit comments

Comments
 (0)