Skip to content

Commit ce551d7

Browse files
committed
refactor(git): remove manifest_reference from GitSource
1 parent 2734097 commit ce551d7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/cargo/sources/git/source.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ use url::Url;
6868
pub struct GitSource<'cfg> {
6969
/// The git remote which we're going to fetch from.
7070
remote: GitRemote,
71-
/// The Git reference from the manifest file.
72-
manifest_reference: GitReference,
7371
/// The revision which a git source is locked to.
7472
///
7573
/// Expected to always be [`Revision::Locked`] after the Git repository is fetched.
@@ -103,7 +101,7 @@ impl<'cfg> GitSource<'cfg> {
103101
assert!(source_id.is_git(), "id is not git, id={}", source_id);
104102

105103
let remote = GitRemote::new(source_id.url());
106-
let manifest_reference = source_id.git_reference().unwrap().clone();
104+
// Fallback to git ref from mainfest if there is no locked revision.
107105
let locked_rev = source_id
108106
.precise_full_git_fragment()
109107
.map(|s| Revision::new(s.into()))
@@ -119,7 +117,6 @@ impl<'cfg> GitSource<'cfg> {
119117

120118
let source = GitSource {
121119
remote,
122-
manifest_reference,
123120
locked_rev,
124121
source_id,
125122
path_source: None,
@@ -239,9 +236,12 @@ impl<'cfg> Debug for GitSource<'cfg> {
239236
// TODO(-Znext-lockfile-bump): set it to true when stabilizing
240237
// lockfile v4, because we want Source ID serialization to be
241238
// consistent with lockfile.
242-
match self.manifest_reference.pretty_ref(false) {
243-
Some(s) => write!(f, " ({})", s),
244-
None => Ok(()),
239+
match &self.locked_rev {
240+
Revision::Deferred(git_ref) => match git_ref.pretty_ref(false) {
241+
Some(s) => write!(f, " ({})", s),
242+
None => Ok(()),
243+
},
244+
Revision::Locked(oid) => write!(f, " ({oid})"),
245245
}
246246
}
247247
}

0 commit comments

Comments
 (0)