1+ //! Helpers to gather the VCS information for `cargo package`.
2+
13use std:: path:: Path ;
24use std:: path:: PathBuf ;
35
@@ -12,13 +14,15 @@ use crate::GlobalContext;
1214
1315use super :: PackageOpts ;
1416
17+ /// Represents the VCS information when packaging.
1518#[ derive( Serialize ) ]
1619pub struct VcsInfo {
1720 git : GitVcsInfo ,
18- /// Path to the package within repo (empty string if root). / not \
21+ /// Path to the package within repo (empty string if root).
1922 path_in_vcs : String ,
2023}
2124
25+ /// Represents the Git VCS information when packaging.
2226#[ derive( Serialize ) ]
2327pub struct GitVcsInfo {
2428 sha1 : String ,
@@ -27,11 +31,13 @@ pub struct GitVcsInfo {
2731 dirty : bool ,
2832}
2933
30- /// Checks if the package source is in a *git* DVCS repository. If *git*, and
31- /// the source is *dirty* (e.g., has uncommitted changes), and `--allow-dirty`
32- /// has not been passed, then `bail!` with an informative message. Otherwise
33- /// return the sha1 hash of the current *HEAD* commit, or `None` if no repo is
34- /// found.
34+ /// Checks if the package source is in a *git* DVCS repository.
35+ ///
36+ /// If *git*, and the source is *dirty* (e.g., has uncommitted changes),
37+ /// and `--allow-dirty` has not been passed,
38+ /// then `bail!` with an informative message.
39+ /// Otherwise return the sha1 hash of the current *HEAD* commit,
40+ /// or `None` if no repo is found.
3541#[ tracing:: instrument( skip_all) ]
3642pub fn check_repo_state (
3743 p : & Package ,
@@ -104,6 +110,7 @@ pub fn check_repo_state(
104110 return Ok ( Some ( VcsInfo { git, path_in_vcs } ) ) ;
105111}
106112
113+ /// The real git status check starts from here.
107114fn git (
108115 pkg : & Package ,
109116 gctx : & GlobalContext ,
0 commit comments