1
+ //! Helpers to gather the VCS information for `cargo package`.
1
2
use crate :: core:: { Package , Workspace } ;
2
- use crate :: ops:: cargo_package:: vcs:: { GitVcsInfo , VcsInfo } ;
3
3
use crate :: ops:: PackageOpts ;
4
4
use crate :: sources:: PathEntry ;
5
5
use crate :: { CargoResult , GlobalContext } ;
@@ -10,10 +10,28 @@ use gix::dir::walk::EmissionMode;
10
10
use gix:: index:: entry:: Mode ;
11
11
use gix:: status:: tree_index:: TrackRenames ;
12
12
use gix:: worktree:: stack:: state:: ignore:: Source ;
13
+ use serde:: Serialize ;
13
14
use std:: collections:: HashSet ;
14
15
use std:: path:: { Path , PathBuf } ;
15
16
use tracing:: debug;
16
17
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
+
17
35
/// Checks if the package source is in a *git* DVCS repository.
18
36
///
19
37
/// If *git*, and the source is *dirty* (e.g., has uncommitted changes),
@@ -64,8 +82,6 @@ pub fn check_repo_state(
64
82
workdir. display( )
65
83
) )
66
84
} ) ?;
67
- // TODO: Either remove this whole block, or have a test.
68
- // It's hard to have no Cargo.toml here?
69
85
// No `Cargo.toml` found. This package may be irrelevant.
70
86
// Have to assume it is clean.
71
87
return Ok ( None ) ;
0 commit comments