Skip to content

Commit 80f48cc

Browse files
committed
Remove the git2 implementation of the cargo-package dirty check.
1 parent f768d42 commit 80f48cc

File tree

5 files changed

+28
-405
lines changed

5 files changed

+28
-405
lines changed

src/cargo/ops/cargo_package/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,7 @@ fn prepare_archive(
479479
let src_files = src.list_files(pkg)?;
480480

481481
// Check (git) repository state, getting the current commit hash.
482-
let vcs_info = if ws.gctx().cli_unstable().gitoxide.is_some() {
483-
vcs::gix::check_repo_state(pkg, &src_files, ws, &opts)
484-
} else {
485-
vcs::check_repo_state(pkg, &src_files, ws, &opts)
486-
}?;
487-
482+
let vcs_info = vcs::check_repo_state(pkg, &src_files, ws, &opts)?;
488483
build_ar_list(ws, pkg, src_files, vcs_info, opts.include_lockfile)
489484
}
490485

src/cargo/ops/cargo_package/vcs/gix.rs renamed to src/cargo/ops/cargo_package/vcs.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
//! Helpers to gather the VCS information for `cargo package`.
12
use crate::core::{Package, Workspace};
2-
use crate::ops::cargo_package::vcs::{GitVcsInfo, VcsInfo};
33
use crate::ops::PackageOpts;
44
use crate::sources::PathEntry;
55
use crate::{CargoResult, GlobalContext};
@@ -10,10 +10,28 @@ use gix::dir::walk::EmissionMode;
1010
use gix::index::entry::Mode;
1111
use gix::status::tree_index::TrackRenames;
1212
use gix::worktree::stack::state::ignore::Source;
13+
use serde::Serialize;
1314
use std::collections::HashSet;
1415
use std::path::{Path, PathBuf};
1516
use tracing::debug;
1617

18+
/// Represents the VCS information when packaging.
19+
#[derive(Serialize)]
20+
pub struct VcsInfo {
21+
git: GitVcsInfo,
22+
/// Path to the package within repo (empty string if root).
23+
path_in_vcs: String,
24+
}
25+
26+
/// Represents the Git VCS information when packaging.
27+
#[derive(Serialize)]
28+
pub struct GitVcsInfo {
29+
sha1: String,
30+
/// Indicate whether the Git worktree is dirty.
31+
#[serde(skip_serializing_if = "std::ops::Not::not")]
32+
dirty: bool,
33+
}
34+
1735
/// Checks if the package source is in a *git* DVCS repository.
1836
///
1937
/// If *git*, and the source is *dirty* (e.g., has uncommitted changes),
@@ -64,8 +82,6 @@ pub fn check_repo_state(
6482
workdir.display()
6583
))
6684
})?;
67-
// TODO: Either remove this whole block, or have a test.
68-
// It's hard to have no Cargo.toml here?
6985
// No `Cargo.toml` found. This package may be irrelevant.
7086
// Have to assume it is clean.
7187
return Ok(None);

0 commit comments

Comments
 (0)