@@ -106,9 +106,13 @@ enum FileContents {
106
106
107
107
enum GeneratedFile {
108
108
/// Generates `Cargo.toml` by rewriting the original.
109
- Manifest ,
110
- /// Generates `Cargo.lock` in some cases (like if there is a binary).
111
- Lockfile ,
109
+ ///
110
+ /// Associated path is the original manifest path.
111
+ Manifest ( PathBuf ) ,
112
+ /// Generates `Cargo.lock`.
113
+ ///
114
+ /// Associated path is the path to the original lock file, if existing.
115
+ Lockfile ( Option < PathBuf > ) ,
112
116
/// Adds a `.cargo_vcs_info.json` file if in a git repo.
113
117
VcsInfo ( vcs:: VcsInfo ) ,
114
118
}
@@ -481,7 +485,9 @@ fn build_ar_list(
481
485
. push ( ArchiveFile {
482
486
rel_path : PathBuf :: from ( "Cargo.toml" ) ,
483
487
rel_str : "Cargo.toml" . to_string ( ) ,
484
- contents : FileContents :: Generated ( GeneratedFile :: Manifest ) ,
488
+ contents : FileContents :: Generated ( GeneratedFile :: Manifest (
489
+ pkg. manifest_path ( ) . to_owned ( ) ,
490
+ ) ) ,
485
491
} ) ;
486
492
} else {
487
493
ws. gctx ( ) . shell ( ) . warn ( & format ! (
@@ -491,14 +497,16 @@ fn build_ar_list(
491
497
}
492
498
493
499
if include_lockfile {
500
+ let lockfile_path = ws. lock_root ( ) . as_path_unlocked ( ) . join ( LOCKFILE_NAME ) ;
501
+ let lockfile_path = lockfile_path. exists ( ) . then_some ( lockfile_path) ;
494
502
let rel_str = "Cargo.lock" ;
495
503
result
496
504
. entry ( UncasedAscii :: new ( rel_str) )
497
505
. or_insert_with ( Vec :: new)
498
506
. push ( ArchiveFile {
499
507
rel_path : PathBuf :: from ( rel_str) ,
500
508
rel_str : rel_str. to_string ( ) ,
501
- contents : FileContents :: Generated ( GeneratedFile :: Lockfile ) ,
509
+ contents : FileContents :: Generated ( GeneratedFile :: Lockfile ( lockfile_path ) ) ,
502
510
} ) ;
503
511
}
504
512
@@ -817,8 +825,10 @@ fn tar(
817
825
}
818
826
FileContents :: Generated ( generated_kind) => {
819
827
let contents = match generated_kind {
820
- GeneratedFile :: Manifest => publish_pkg. manifest ( ) . to_normalized_contents ( ) ?,
821
- GeneratedFile :: Lockfile => build_lock ( ws, & publish_pkg, local_reg) ?,
828
+ GeneratedFile :: Manifest ( _) => {
829
+ publish_pkg. manifest ( ) . to_normalized_contents ( ) ?
830
+ }
831
+ GeneratedFile :: Lockfile ( _) => build_lock ( ws, & publish_pkg, local_reg) ?,
822
832
GeneratedFile :: VcsInfo ( ref s) => serde_json:: to_string_pretty ( s) ?,
823
833
} ;
824
834
header. set_entry_type ( EntryType :: file ( ) ) ;
0 commit comments