@@ -10,6 +10,7 @@ use serde::Serialize;
10
10
use tracing:: debug;
11
11
12
12
use crate :: core:: Package ;
13
+ use crate :: core:: Workspace ;
13
14
use crate :: sources:: PathEntry ;
14
15
use crate :: CargoResult ;
15
16
use crate :: GlobalContext ;
@@ -44,9 +45,10 @@ pub struct GitVcsInfo {
44
45
pub fn check_repo_state (
45
46
p : & Package ,
46
47
src_files : & [ PathEntry ] ,
47
- gctx : & GlobalContext ,
48
+ ws : & Workspace < ' _ > ,
48
49
opts : & PackageOpts < ' _ > ,
49
50
) -> CargoResult < Option < VcsInfo > > {
51
+ let gctx = ws. gctx ( ) ;
50
52
let Ok ( repo) = git2:: Repository :: discover ( p. root ( ) ) else {
51
53
gctx. shell ( ) . verbose ( |shell| {
52
54
shell. warn ( format_args ! (
@@ -103,7 +105,7 @@ pub fn check_repo_state(
103
105
path. display( ) ,
104
106
workdir. display( ) ,
105
107
) ;
106
- let Some ( git) = git ( p , gctx , src_files, & repo, & opts) ? else {
108
+ let Some ( git) = git ( ws , p , src_files, & repo, & opts) ? else {
107
109
// If the git repo lacks essensial field like `sha1`, and since this field exists from the beginning,
108
110
// then don't generate the corresponding file in order to maintain consistency with past behavior.
109
111
return Ok ( None ) ;
@@ -166,8 +168,8 @@ fn warn_symlink_checked_out_as_plain_text_file(
166
168
167
169
/// The real git status check starts from here.
168
170
fn git (
171
+ ws : & Workspace < ' _ > ,
169
172
pkg : & Package ,
170
- gctx : & GlobalContext ,
171
173
src_files : & [ PathEntry ] ,
172
174
repo : & git2:: Repository ,
173
175
opts : & PackageOpts < ' _ > ,
@@ -188,12 +190,12 @@ fn git(
188
190
// Find the intersection of dirty in git, and the src_files that would
189
191
// be packaged. This is a lazy n^2 check, but seems fine with
190
192
// thousands of files.
191
- let cwd = gctx. cwd ( ) ;
193
+ let cwd = ws . gctx ( ) . cwd ( ) ;
192
194
let mut dirty_src_files: Vec < _ > = src_files
193
195
. iter ( )
194
196
. filter ( |src_file| dirty_files. iter ( ) . any ( |path| src_file. starts_with ( path) ) )
195
197
. map ( |p| p. as_ref ( ) )
196
- . chain ( dirty_files_outside_pkg_root ( pkg, repo, src_files) ?. iter ( ) )
198
+ . chain ( dirty_files_outside_pkg_root ( ws , pkg, repo, src_files) ?. iter ( ) )
197
199
. map ( |path| {
198
200
pathdiff:: diff_paths ( path, cwd)
199
201
. as_ref ( )
@@ -232,11 +234,13 @@ fn git(
232
234
///
233
235
/// * `package.readme` and `package.license-file` pointing to paths outside package root
234
236
/// * symlinks targets reside outside package root
237
+ /// * Any change in the root workspace manifest, regardless of what has changed.
235
238
///
236
239
/// This is required because those paths may link to a file outside the
237
240
/// current package root, but still under the git workdir, affecting the
238
241
/// final packaged `.crate` file.
239
242
fn dirty_files_outside_pkg_root (
243
+ ws : & Workspace < ' _ > ,
240
244
pkg : & Package ,
241
245
repo : & git2:: Repository ,
242
246
src_files : & [ PathEntry ] ,
@@ -255,8 +259,9 @@ fn dirty_files_outside_pkg_root(
255
259
for rel_path in src_files
256
260
. iter ( )
257
261
. filter ( |p| p. is_symlink_or_under_symlink ( ) )
258
- . map ( |p| p. as_ref ( ) )
259
- . chain ( metadata_paths. iter ( ) )
262
+ . map ( |p| p. as_ref ( ) . as_path ( ) )
263
+ . chain ( metadata_paths. iter ( ) . map ( AsRef :: as_ref) )
264
+ . chain ( [ ws. root_manifest ( ) ] )
260
265
// If inside package root. Don't bother checking git status.
261
266
. filter ( |p| paths:: strip_prefix_canonical ( p, pkg_root) . is_err ( ) )
262
267
// Handle files outside package root but under git workdir,
0 commit comments