collin/anvil · 2b7e7397
style: collapse multiline imports via rustfmt
Collin Richards · 2026-06-09 21:51 UTC · 2b7e739752efa97343ac757a425632d15204c80a · parent 7f97cf80 · browse files
modifiedcrates/anvil-core/src/access.rs+1 −4
| ⋯ 3 unchanged lines | |||
| 4 | 4 | //! a repo is owned by one user; private repos are visible only to their owner; | |
| 5 | 5 | //! writes (push) and settings changes are owner-only. Admins may do anything. | |
| 6 | 6 | ||
| 7 | - | use crate::models::{ | |
| 8 | - | Repository, | |
| 9 | - | User, | |
| 10 | - | }; | |
| 7 | + | use crate::models::{Repository, User}; | |
| 11 | 8 | ||
| 12 | 9 | /// Whether `viewer` may read (browse / clone) `repo`. | |
| 13 | 10 | pub fn can_read(repo: &Repository, viewer: Option<&User>) -> bool { | |
| ⋯ 10 unchanged lines | |||
modifiedcrates/anvil-core/src/db.rs+1 −7
| ⋯ 2 unchanged lines | |||
| 3 | 3 | use std::path::Path; | |
| 4 | 4 | ||
| 5 | 5 | use crate::error::Result; | |
| 6 | - | use crate::models::{ | |
| 7 | - | CiRun, | |
| 8 | - | Repository, | |
| 9 | - | Session, | |
| 10 | - | SshKey, | |
| 11 | - | User, | |
| 12 | - | }; | |
| 6 | + | use crate::models::{CiRun, Repository, Session, SshKey, User}; | |
| 13 | 7 | ||
| 14 | 8 | /// Open (creating if necessary) the SQLite database at `path`, creating the | |
| 15 | 9 | /// schema on first run. | |
| ⋯ 22 unchanged lines | |||
modifiedcrates/anvil-core/src/repos.rs+2 −8
| ⋯ 1 unchanged line | |||
| 2 | 2 | ||
| 3 | 3 | use std::path::Path; | |
| 4 | 4 | ||
| 5 | - | use crate::error::{ | |
| 6 | - | Error, | |
| 7 | - | Result, | |
| 8 | - | }; | |
| 9 | - | use crate::models::{ | |
| 10 | - | Repository, | |
| 11 | - | User, | |
| 12 | - | }; | |
| 5 | + | use crate::error::{Error, Result}; | |
| 6 | + | use crate::models::{Repository, User}; | |
| 13 | 7 | use crate::storage; | |
| 14 | 8 | ||
| 15 | 9 | /// A repository joined with its owner's username, for listing pages. | |
| ⋯ 141 unchanged lines | |||
modifiedcrates/anvil-core/src/sessions.rs+2 −8
| 1 | 1 | //! Web login sessions: opaque random tokens stored server-side and referenced | |
| 2 | 2 | //! by a cookie. | |
| 3 | 3 | ||
| 4 | - | use argon2::password_hash::rand_core::{ | |
| 5 | - | OsRng, | |
| 6 | - | RngCore, | |
| 7 | - | }; | |
| 4 | + | use argon2::password_hash::rand_core::{OsRng, RngCore}; | |
| 8 | 5 | ||
| 9 | 6 | use crate::error::Result; | |
| 10 | - | use crate::models::{ | |
| 11 | - | Session, | |
| 12 | - | User, | |
| 13 | - | }; | |
| 7 | + | use crate::models::{Session, User}; | |
| 14 | 8 | ||
| 15 | 9 | /// Default session lifetime: 30 days. | |
| 16 | 10 | const SESSION_TTL_SECS: i64 = 60 * 60 * 24 * 30; | |
| ⋯ 63 unchanged lines | |||
modifiedcrates/anvil-core/src/ssh_keys.rs+2 −8
| 1 | 1 | //! SSH public keys: parsing, registration, and lookup for git-over-SSH | |
| 2 | 2 | //! authentication. | |
| 3 | 3 | ||
| 4 | - | use ssh_key::{ | |
| 5 | - | HashAlg, | |
| 6 | - | PublicKey, | |
| 7 | - | }; | |
| 4 | + | use ssh_key::{HashAlg, PublicKey}; | |
| 8 | 5 | ||
| 9 | - | use crate::error::{ | |
| 10 | - | Error, | |
| 11 | - | Result, | |
| 12 | - | }; | |
| 6 | + | use crate::error::{Error, Result}; | |
| 13 | 7 | use crate::models::SshKey; | |
| 14 | 8 | ||
| 15 | 9 | /// Parse an OpenSSH public-key line (`ssh-ed25519 AAAA… comment`) into its | |
| ⋯ 83 unchanged lines | |||
modifiedcrates/anvil-core/src/storage.rs+3 −14
| ⋯ 4 unchanged lines | |||
| 5 | 5 | //! between forge identities and filesystem paths, plus creation/opening via | |
| 6 | 6 | //! `gix`. No database access happens here. | |
| 7 | 7 | ||
| 8 | - | use std::path::{ | |
| 9 | - | Path, | |
| 10 | - | PathBuf, | |
| 11 | - | }; | |
| 8 | + | use std::path::{Path, PathBuf}; | |
| 12 | 9 | ||
| 13 | - | use crate::error::{ | |
| 14 | - | Error, | |
| 15 | - | Result, | |
| 16 | - | }; | |
| 10 | + | use crate::error::{Error, Result}; | |
| 17 | 11 | ||
| 18 | 12 | /// Compute the on-disk path of a bare repository. | |
| 19 | 13 | pub fn repo_path(repositories_dir: &Path, owner: &str, name: &str) -> PathBuf { | |
| ⋯ 33 unchanged lines | |||
| 53 | 47 | /// Point `HEAD` at `refs/heads/<branch>` as a symbolic reference. | |
| 54 | 48 | fn set_head_branch(repo: &gix::Repository, branch: &str) -> Result<()> { | |
| 55 | 49 | use gix::refs::Target; | |
| 56 | - | use gix::refs::transaction::{ | |
| 57 | - | Change, | |
| 58 | - | LogChange, | |
| 59 | - | PreviousValue, | |
| 60 | - | RefEdit, | |
| 61 | - | }; | |
| 50 | + | use gix::refs::transaction::{Change, LogChange, PreviousValue, RefEdit}; | |
| 62 | 51 | ||
| 63 | 52 | let target_name: gix::refs::FullName = format!("refs/heads/{branch}") | |
| 64 | 53 | .try_into() | |
| ⋯ 23 unchanged lines | |||
modifiedcrates/anvil-core/src/users.rs+2 −10
| ⋯ 1 unchanged line | |||
| 2 | 2 | ||
| 3 | 3 | use argon2::Argon2; | |
| 4 | 4 | use argon2::password_hash::rand_core::OsRng; | |
| 5 | - | use argon2::password_hash::{ | |
| 6 | - | PasswordHash, | |
| 7 | - | PasswordHasher, | |
| 8 | - | PasswordVerifier, | |
| 9 | - | SaltString, | |
| 10 | - | }; | |
| 5 | + | use argon2::password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString}; | |
| 11 | 6 | ||
| 12 | - | use crate::error::{ | |
| 13 | - | Error, | |
| 14 | - | Result, | |
| 15 | - | }; | |
| 7 | + | use crate::error::{Error, Result}; | |
| 16 | 8 | use crate::models::User; | |
| 17 | 9 | ||
| 18 | 10 | /// Usernames reserved for system use — they collide with (or could be confused | |
| ⋯ 94 unchanged lines | |||
modifiedcrates/anvil-git/src/lib.rs+2 −8
| ⋯ 18 unchanged lines | |||
| 19 | 19 | pub mod ssh; | |
| 20 | 20 | pub mod trigger; | |
| 21 | 21 | ||
| 22 | - | pub use error::{ | |
| 23 | - | Error, | |
| 24 | - | Result, | |
| 25 | - | }; | |
| 26 | - | pub use smart_http::{ | |
| 27 | - | Service, | |
| 28 | - | UploadPack, | |
| 29 | - | }; | |
| 22 | + | pub use error::{Error, Result}; | |
| 23 | + | pub use smart_http::{Service, UploadPack}; | |
modifiedcrates/anvil-git/src/smart_http.rs+1 −5
| ⋯ 13 unchanged lines | |||
| 14 | 14 | use std::pin::Pin; | |
| 15 | 15 | ||
| 16 | 16 | use gitserver_core::backend::GitBackend; | |
| 17 | - | use gitserver_core::{ | |
| 18 | - | pack, | |
| 19 | - | pktline, | |
| 20 | - | protocol_v2, | |
| 21 | - | }; | |
| 17 | + | use gitserver_core::{pack, pktline, protocol_v2}; | |
| 22 | 18 | use tokio::io::AsyncRead; | |
| 23 | 19 | ||
| 24 | 20 | use crate::error::Result; | |
| ⋯ 131 unchanged lines | |||
modifiedcrates/anvil-git/src/ssh.rs+2 −11
| ⋯ 11 unchanged lines | |||
| 12 | 12 | use std::path::Path; | |
| 13 | 13 | ||
| 14 | 14 | use gitserver_core::backend::GitBackend; | |
| 15 | - | use tokio::io::{ | |
| 16 | - | AsyncRead, | |
| 17 | - | AsyncReadExt, | |
| 18 | - | AsyncWrite, | |
| 19 | - | AsyncWriteExt, | |
| 20 | - | }; | |
| 15 | + | use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; | |
| 21 | 16 | ||
| 22 | 17 | use crate::error::Result; | |
| 23 | - | use crate::smart_http::{ | |
| 24 | - | self, | |
| 25 | - | Service, | |
| 26 | - | UploadPack, | |
| 27 | - | }; | |
| 18 | + | use crate::smart_http::{self, Service, UploadPack}; | |
| 28 | 19 | ||
| 29 | 20 | /// Parse an SSH `exec` command such as `git-upload-pack '/alice/hello.git'`, | |
| 30 | 21 | /// returning the service and the (leading-slash-trimmed) repository path. | |
| ⋯ 198 unchanged lines | |||
modifiedvendor/gitserver-core/src/backend.rs+3 −13
| 1 | 1 | use std::path::PathBuf; | |
| 2 | 2 | use std::pin::Pin; | |
| 3 | 3 | use std::sync::Arc; | |
| 4 | - | use std::sync::atomic::{ | |
| 5 | - | AtomicBool, | |
| 6 | - | Ordering, | |
| 7 | - | }; | |
| 8 | - | use std::task::{ | |
| 9 | - | Context, | |
| 10 | - | Poll, | |
| 11 | - | }; | |
| 4 | + | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 5 | + | use std::task::{Context, Poll}; | |
| 12 | 6 | ||
| 13 | 7 | use tokio::io::AsyncRead; | |
| 14 | - | use tokio::time::{ | |
| 15 | - | Duration, | |
| 16 | - | Sleep, | |
| 17 | - | sleep, | |
| 18 | - | }; | |
| 8 | + | use tokio::time::{Duration, Sleep, sleep}; | |
| 19 | 9 | use tokio_util::io::SyncIoBridge; | |
| 20 | 10 | ||
| 21 | 11 | use crate::error::Result; | |
| ⋯ 230 unchanged lines | |||
modifiedvendor/gitserver-core/src/discovery.rs+3 −13
| 1 | 1 | use std::fs; | |
| 2 | - | use std::path::{ | |
| 3 | - | Path, | |
| 4 | - | PathBuf, | |
| 5 | - | }; | |
| 2 | + | use std::path::{Path, PathBuf}; | |
| 6 | 3 | ||
| 7 | 4 | use serde::Serialize; | |
| 8 | 5 | ||
| 9 | - | pub use crate::dynamic_registry::{ | |
| 10 | - | DynamicRepoRegistry, | |
| 11 | - | MutableRepoRegistry, | |
| 12 | - | RepoResolver, | |
| 13 | - | }; | |
| 14 | - | use crate::error::{ | |
| 15 | - | Error, | |
| 16 | - | Result, | |
| 17 | - | }; | |
| 6 | + | pub use crate::dynamic_registry::{DynamicRepoRegistry, MutableRepoRegistry, RepoResolver}; | |
| 7 | + | use crate::error::{Error, Result}; | |
| 18 | 8 | ||
| 19 | 9 | const DEFAULT_GIT_DESCRIPTION: &str = | |
| 20 | 10 | "Unnamed repository; edit this file 'description' to name the repository."; | |
| ⋯ 285 unchanged lines | |||
modifiedvendor/gitserver-core/src/dynamic_registry.rs+4 −16
| ⋯ 3 unchanged lines | |||
| 4 | 4 | // | |
| 5 | 5 | // Copyright (c) 2026 WJQSERVER | |
| 6 | 6 | ||
| 7 | - | use std::path::{ | |
| 8 | - | Path, | |
| 9 | - | PathBuf, | |
| 10 | - | }; | |
| 11 | - | use std::sync::{ | |
| 12 | - | Arc, | |
| 13 | - | RwLock, | |
| 14 | - | }; | |
| 7 | + | use std::path::{Path, PathBuf}; | |
| 8 | + | use std::sync::{Arc, RwLock}; | |
| 15 | 9 | ||
| 16 | - | use crate::discovery::{ | |
| 17 | - | RepoInfo, | |
| 18 | - | RepoStore, | |
| 19 | - | }; | |
| 20 | - | use crate::error::{ | |
| 21 | - | Error, | |
| 22 | - | Result, | |
| 23 | - | }; | |
| 10 | + | use crate::discovery::{RepoInfo, RepoStore}; | |
| 11 | + | use crate::error::{Error, Result}; | |
| 24 | 12 | ||
| 25 | 13 | pub trait RepoResolver: Send + Sync { | |
| 26 | 14 | fn resolve(&self, relative: &str) -> Result<RepoInfo>; | |
| ⋯ 249 unchanged lines | |||
modifiedvendor/gitserver-core/src/pack.rs+3 −12
| ⋯ 1 unchanged line | |||
| 2 | 2 | use std::path::Path; | |
| 3 | 3 | ||
| 4 | 4 | use bytes::Bytes; | |
| 5 | - | use sha1::{ | |
| 6 | - | Digest, | |
| 7 | - | Sha1, | |
| 8 | - | }; | |
| 5 | + | use sha1::{Digest, Sha1}; | |
| 9 | 6 | use tokio::io::AsyncRead; | |
| 10 | 7 | use tokio_util::io::StreamReader; | |
| 11 | 8 | ||
| 12 | - | use crate::error::{ | |
| 13 | - | Error, | |
| 14 | - | Result, | |
| 15 | - | }; | |
| 9 | + | use crate::error::{Error, Result}; | |
| 16 | 10 | use crate::pktline; | |
| 17 | 11 | ||
| 18 | 12 | #[derive(Debug, Clone, Default)] | |
| ⋯ 637 unchanged lines | |||
| 656 | 650 | ||
| 657 | 651 | #[cfg(test)] | |
| 658 | 652 | mod tests { | |
| 659 | - | use std::path::{ | |
| 660 | - | Path, | |
| 661 | - | PathBuf, | |
| 662 | - | }; | |
| 653 | + | use std::path::{Path, PathBuf}; | |
| 663 | 654 | use std::process::Command; | |
| 664 | 655 | ||
| 665 | 656 | use tempfile::TempDir; | |
| ⋯ 183 unchanged lines | |||
modifiedvendor/gitserver-core/src/path.rs+2 −9
| 1 | - | use std::path::{ | |
| 2 | - | Component, | |
| 3 | - | Path, | |
| 4 | - | PathBuf, | |
| 5 | - | }; | |
| 1 | + | use std::path::{Component, Path, PathBuf}; | |
| 6 | 2 | ||
| 7 | - | use crate::error::{ | |
| 8 | - | Error, | |
| 9 | - | Result, | |
| 10 | - | }; | |
| 3 | + | use crate::error::{Error, Result}; | |
| 11 | 4 | ||
| 12 | 5 | /// Normalize a path by resolving `.` and `..` components lexically, | |
| 13 | 6 | /// without touching the filesystem. | |
| ⋯ 90 unchanged lines | |||
modifiedvendor/gitserver-core/src/protocol_v2.rs+2 −8
| ⋯ 8 unchanged lines | |||
| 9 | 9 | use std::io::Cursor; | |
| 10 | 10 | use std::path::Path; | |
| 11 | 11 | ||
| 12 | - | use crate::error::{ | |
| 13 | - | Error, | |
| 14 | - | Result, | |
| 15 | - | }; | |
| 12 | + | use crate::error::{Error, Result}; | |
| 16 | 13 | use crate::pack::UploadPackRequest; | |
| 17 | 14 | use crate::pktline; | |
| 18 | 15 | ||
| ⋯ 566 unchanged lines | |||
| 585 | 582 | request: &crate::pack::UploadPackRequest, | |
| 586 | 583 | depth: usize, | |
| 587 | 584 | ) -> Result<DepthState> { | |
| 588 | - | use std::collections::{ | |
| 589 | - | HashSet, | |
| 590 | - | VecDeque, | |
| 591 | - | }; | |
| 585 | + | use std::collections::{HashSet, VecDeque}; | |
| 592 | 586 | ||
| 593 | 587 | let mut queue = VecDeque::new(); | |
| 594 | 588 | let mut seen = HashSet::new(); | |
| ⋯ 158 unchanged lines | |||
modifiedvendor/gitserver-core/src/receive_pack.rs+3 −16
| ⋯ 3 unchanged lines | |||
| 4 | 4 | // | |
| 5 | 5 | // Copyright (c) 2026 WJQSERVER | |
| 6 | 6 | ||
| 7 | - | use std::io::{ | |
| 8 | - | BufRead, | |
| 9 | - | BufReader, | |
| 10 | - | Read, | |
| 11 | - | }; | |
| 7 | + | use std::io::{BufRead, BufReader, Read}; | |
| 12 | 8 | use std::path::Path; | |
| 13 | 9 | use std::sync::atomic::AtomicBool; | |
| 14 | 10 | ||
| ⋯ 1 unchanged line | |||
| 16 | 12 | use gix::prelude::ObjectIdExt; | |
| 17 | 13 | use gix::progress::Discard; | |
| 18 | 14 | use gix::refs::Target; | |
| 19 | - | use gix::refs::transaction::{ | |
| 20 | - | Change, | |
| 21 | - | LogChange, | |
| 22 | - | PreviousValue, | |
| 23 | - | RefEdit, | |
| 24 | - | RefLog, | |
| 25 | - | }; | |
| 15 | + | use gix::refs::transaction::{Change, LogChange, PreviousValue, RefEdit, RefLog}; | |
| 26 | 16 | ||
| 27 | - | use crate::error::{ | |
| 28 | - | Error, | |
| 29 | - | Result, | |
| 30 | - | }; | |
| 17 | + | use crate::error::{Error, Result}; | |
| 31 | 18 | use crate::pktline; | |
| 32 | 19 | ||
| 33 | 20 | const ZERO_ID: &str = "0000000000000000000000000000000000000000"; | |
| ⋯ 529 unchanged lines | |||
modifiedvendor/gitserver-core/src/refs.rs+1 −4
| ⋯ 73 unchanged lines | |||
| 74 | 74 | ||
| 75 | 75 | #[cfg(test)] | |
| 76 | 76 | mod tests { | |
| 77 | - | use std::path::{ | |
| 78 | - | Path, | |
| 79 | - | PathBuf, | |
| 80 | - | }; | |
| 77 | + | use std::path::{Path, PathBuf}; | |
| 81 | 78 | use std::process::Command; | |
| 82 | 79 | ||
| 83 | 80 | use tempfile::TempDir; | |
| ⋯ 140 unchanged lines | |||