mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-26 18:06:45 +00:00
Clippy pedantic (#1963)
Address a few pedantic lints lints are separated into separate commits so they can be reviewed individually. I've not added enforcement for any of these lints, but that could be added if desirable.
This commit is contained in:
parent
b052291685
commit
8d721830db
68 changed files with 635 additions and 673 deletions
|
|
@ -8,7 +8,7 @@ use std::{env, str};
|
|||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use cargo_util::{paths, ProcessBuilder};
|
||||
use git2::{self, ErrorClass, ObjectType};
|
||||
use git2::{ErrorClass, ObjectType};
|
||||
use reqwest::Client;
|
||||
use reqwest::StatusCode;
|
||||
use tracing::{debug, warn};
|
||||
|
|
@ -69,25 +69,25 @@ impl GitReference {
|
|||
/// Views the short ID as a `str`.
|
||||
pub(crate) fn as_str(&self) -> &str {
|
||||
match self {
|
||||
GitReference::Branch(rev)
|
||||
| GitReference::Tag(rev)
|
||||
| GitReference::BranchOrTag(rev)
|
||||
| GitReference::FullCommit(rev)
|
||||
| GitReference::ShortCommit(rev)
|
||||
| GitReference::Ref(rev) => rev,
|
||||
GitReference::DefaultBranch => "HEAD",
|
||||
Self::Branch(rev)
|
||||
| Self::Tag(rev)
|
||||
| Self::BranchOrTag(rev)
|
||||
| Self::FullCommit(rev)
|
||||
| Self::ShortCommit(rev)
|
||||
| Self::Ref(rev) => rev,
|
||||
Self::DefaultBranch => "HEAD",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn kind_str(&self) -> &str {
|
||||
match self {
|
||||
GitReference::Branch(_) => "branch",
|
||||
GitReference::Tag(_) => "tag",
|
||||
GitReference::BranchOrTag(_) => "branch or tag",
|
||||
GitReference::FullCommit(_) => "commit",
|
||||
GitReference::ShortCommit(_) => "short commit",
|
||||
GitReference::Ref(_) => "ref",
|
||||
GitReference::DefaultBranch => "default branch",
|
||||
Self::Branch(_) => "branch",
|
||||
Self::Tag(_) => "tag",
|
||||
Self::BranchOrTag(_) => "branch or tag",
|
||||
Self::FullCommit(_) => "commit",
|
||||
Self::ShortCommit(_) => "short commit",
|
||||
Self::Ref(_) => "ref",
|
||||
Self::DefaultBranch => "default branch",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,8 +136,8 @@ pub(crate) struct GitCheckout<'a> {
|
|||
|
||||
impl GitRemote {
|
||||
/// Creates an instance for a remote repository URL.
|
||||
pub(crate) fn new(url: &Url) -> GitRemote {
|
||||
GitRemote { url: url.clone() }
|
||||
pub(crate) fn new(url: &Url) -> Self {
|
||||
Self { url: url.clone() }
|
||||
}
|
||||
|
||||
/// Gets the remote repository URL.
|
||||
|
|
@ -261,7 +261,7 @@ impl GitReference {
|
|||
let id = match self {
|
||||
// Note that we resolve the named tag here in sync with where it's
|
||||
// fetched into via `fetch` below.
|
||||
GitReference::Tag(s) => (|| -> Result<git2::Oid> {
|
||||
Self::Tag(s) => (|| -> Result<git2::Oid> {
|
||||
let refname = format!("refs/remotes/origin/tags/{s}");
|
||||
let id = repo.refname_to_id(&refname)?;
|
||||
let obj = repo.find_object(id, None)?;
|
||||
|
|
@ -272,7 +272,7 @@ impl GitReference {
|
|||
|
||||
// Resolve the remote name since that's all we're configuring in
|
||||
// `fetch` below.
|
||||
GitReference::Branch(s) => {
|
||||
Self::Branch(s) => {
|
||||
let name = format!("origin/{s}");
|
||||
let b = repo
|
||||
.find_branch(&name, git2::BranchType::Remote)
|
||||
|
|
@ -283,7 +283,7 @@ impl GitReference {
|
|||
}
|
||||
|
||||
// Attempt to resolve the branch, then the tag.
|
||||
GitReference::BranchOrTag(s) => {
|
||||
Self::BranchOrTag(s) => {
|
||||
let name = format!("origin/{s}");
|
||||
|
||||
repo.find_branch(&name, git2::BranchType::Remote)
|
||||
|
|
@ -300,13 +300,13 @@ impl GitReference {
|
|||
}
|
||||
|
||||
// We'll be using the HEAD commit
|
||||
GitReference::DefaultBranch => {
|
||||
Self::DefaultBranch => {
|
||||
let head_id = repo.refname_to_id("refs/remotes/origin/HEAD")?;
|
||||
let head = repo.find_object(head_id, None)?;
|
||||
head.peel(ObjectType::Commit)?.id()
|
||||
}
|
||||
|
||||
GitReference::FullCommit(s) | GitReference::ShortCommit(s) | GitReference::Ref(s) => {
|
||||
Self::FullCommit(s) | Self::ShortCommit(s) | Self::Ref(s) => {
|
||||
let obj = repo.revparse_single(s)?;
|
||||
match obj.as_tag() {
|
||||
Some(tag) => tag.target_id(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue