Skip to content

Commit 866afb2

Browse files
committed
fix: remove list owners feature of info subcommand
1 parent ff6df29 commit 866afb2

File tree

8 files changed

+13
-108
lines changed

8 files changed

+13
-108
lines changed

src/cargo/ops/registry/info/mod.rs

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Implementation of `cargo info`.
22
33
use anyhow::bail;
4-
use cargo_credential::Operation;
54
use cargo_util_schemas::core::{PackageIdSpec, PartialVersion};
6-
use crates_io::User;
75

86
use crate::core::registry::PackageRegistry;
97
use crate::core::{Dependency, Package, PackageId, PackageIdSpecQuery, Registry, Workspace};
@@ -12,7 +10,6 @@ use crate::ops::registry::{get_source_id_with_package_id, RegistryOrIndex, Regis
1210
use crate::ops::resolve_ws;
1311
use crate::sources::source::QueryKind;
1412
use crate::sources::{IndexSummary, SourceConfigMap};
15-
use crate::util::auth::AuthorizationErrorReason;
1613
use crate::util::cache_lock::CacheLockMode;
1714
use crate::util::command_prelude::root_manifest;
1815
use crate::{CargoResult, GlobalContext};
@@ -79,19 +76,7 @@ pub fn info(
7976

8077
let package = registry.get(&[package_id])?;
8178
let package = package.get_one(package_id)?;
82-
let owners = try_list_owners(
83-
gctx,
84-
&source_ids,
85-
reg_or_index.as_ref(),
86-
package_id.name().as_str(),
87-
)?;
88-
pretty_view(
89-
package,
90-
&summaries,
91-
&owners,
92-
suggest_cargo_tree_command,
93-
gctx,
94-
)?;
79+
pretty_view(package, &summaries, suggest_cargo_tree_command, gctx)?;
9580

9681
Ok(())
9782
}
@@ -207,56 +192,6 @@ fn query_summaries(
207192
}
208193
}
209194

210-
// Try to list the login and name of all owners of a crate.
211-
fn try_list_owners(
212-
gctx: &GlobalContext,
213-
source_ids: &RegistrySourceIds,
214-
reg_or_index: Option<&RegistryOrIndex>,
215-
package_name: &str,
216-
) -> CargoResult<Option<Vec<String>>> {
217-
// Only remote registries support listing owners.
218-
if !source_ids.original.is_remote_registry() {
219-
return Ok(None);
220-
}
221-
match super::registry(
222-
gctx,
223-
source_ids,
224-
None,
225-
reg_or_index,
226-
false,
227-
Some(Operation::Read),
228-
) {
229-
Ok(mut registry) => {
230-
let owners = registry.list_owners(package_name)?;
231-
let names = owners.iter().map(get_username).collect();
232-
return Ok(Some(names));
233-
}
234-
Err(err) => {
235-
// If the token is missing, it means the user is not logged in.
236-
// We don't want to show an error in this case.
237-
if err.to_string().contains(
238-
(AuthorizationErrorReason::TokenMissing)
239-
.to_string()
240-
.as_str(),
241-
) {
242-
return Ok(None);
243-
}
244-
return Err(err);
245-
}
246-
}
247-
}
248-
249-
fn get_username(u: &User) -> String {
250-
format!(
251-
"{}{}",
252-
u.login,
253-
u.name
254-
.as_ref()
255-
.map(|name| format!(" ({})", name))
256-
.unwrap_or_default(),
257-
)
258-
}
259-
260195
fn validate_locked_and_frozen_options(
261196
in_workspace: bool,
262197
gctx: &GlobalContext,

src/cargo/ops/registry/info/view.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use crate::{
1515
pub(super) fn pretty_view(
1616
package: &Package,
1717
summaries: &[IndexSummary],
18-
owners: &Option<Vec<String>>,
1918
suggest_cargo_tree_command: bool,
2019
gctx: &GlobalContext,
2120
) -> CargoResult<()> {
@@ -153,10 +152,6 @@ pub(super) fn pretty_view(
153152
gctx,
154153
)?;
155154

156-
if let Some(owners) = owners {
157-
pretty_owners(owners, stdout)?;
158-
}
159-
160155
if suggest_cargo_tree_command {
161156
suggest_cargo_tree(package_id, stdout)?;
162157
}
@@ -399,19 +394,6 @@ fn pretty_features(
399394
Ok(())
400395
}
401396

402-
fn pretty_owners(owners: &Vec<String>, stdout: &mut dyn Write) -> CargoResult<()> {
403-
let header = HEADER;
404-
405-
if !owners.is_empty() {
406-
writeln!(stdout, "{header}owners:{header:#}",)?;
407-
for owner in owners {
408-
writeln!(stdout, " {}", owner)?;
409-
}
410-
}
411-
412-
Ok(())
413-
}
414-
415397
// Suggest the cargo tree command to view the dependency tree.
416398
fn suggest_cargo_tree(package_id: PackageId, stdout: &mut dyn Write) -> CargoResult<()> {
417399
let literal = LITERAL;

tests/testsuite/cargo_info/features_activated_over_limit_verbose/stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

tests/testsuite/cargo_info/verbose/stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

tests/testsuite/cargo_info/within_ws/stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg

Lines changed: 2 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)