Skip to content

Commit 4244b64

Browse files
committed
refactor(package): move path_in_vcs closer to where it is used
1 parent af1e77c commit 4244b64

File tree

1 file changed

+6
-5
lines changed
  • src/cargo/ops/cargo_package

1 file changed

+6
-5
lines changed

src/cargo/ops/cargo_package/vcs.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,18 @@ pub fn check_repo_state(
100100
path.display(),
101101
workdir.display(),
102102
);
103-
let path_in_vcs = path
104-
.parent()
105-
.and_then(|p| p.to_str())
106-
.unwrap_or("")
107-
.replace("\\", "/");
108103
let Some(git) = git(p, gctx, src_files, &repo, &opts)? else {
109104
// If the git repo lacks essensial field like `sha1`, and since this field exists from the beginning,
110105
// then don't generate the corresponding file in order to maintain consistency with past behavior.
111106
return Ok(None);
112107
};
113108

109+
let path_in_vcs = path
110+
.parent()
111+
.and_then(|p| p.to_str())
112+
.unwrap_or("")
113+
.replace("\\", "/");
114+
114115
return Ok(Some(VcsInfo { git, path_in_vcs }));
115116
}
116117

0 commit comments

Comments
 (0)