Skip to content

Commit 34e1a3d

Browse files
committed
feat: Report repository as fallback from homepage
Fixes #77 Closes #78
1 parent e9580d7 commit 34e1a3d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct Metadata {
6464
version: Cow<'static, str>,
6565
authors: Option<Cow<'static, str>>,
6666
homepage: Option<Cow<'static, str>>,
67+
repository: Option<Cow<'static, str>>,
6768
support: Option<Cow<'static, str>>,
6869
}
6970

@@ -75,6 +76,7 @@ impl Metadata {
7576
version: version.into(),
7677
authors: None,
7778
homepage: None,
79+
repository: None,
7880
support: None,
7981
}
8082
}
@@ -97,6 +99,15 @@ impl Metadata {
9799
self
98100
}
99101

102+
/// The URL of the crate's repository
103+
pub fn repository(mut self, value: impl Into<Cow<'static, str>>) -> Self {
104+
let value = value.into();
105+
if !value.is_empty() {
106+
self.repository = value.into();
107+
}
108+
self
109+
}
110+
100111
/// The support information
101112
pub fn support(mut self, value: impl Into<Cow<'static, str>>) -> Self {
102113
let value = value.into();
@@ -114,6 +125,7 @@ macro_rules! metadata {
114125
$crate::Metadata::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"))
115126
.authors(env!("CARGO_PKG_AUTHORS").replace(":", ", "))
116127
.homepage(env!("CARGO_PKG_HOMEPAGE"))
128+
.repository(env!("CARGO_PKG_REPOSITORY"))
117129
}};
118130
}
119131

@@ -228,6 +240,7 @@ fn write_msg<P: AsRef<Path>>(
228240
name,
229241
authors,
230242
homepage,
243+
repository,
231244
support,
232245
..
233246
} = meta;
@@ -252,6 +265,8 @@ fn write_msg<P: AsRef<Path>>(
252265

253266
if let Some(homepage) = homepage {
254267
writeln!(buffer, "- Homepage: {homepage}")?;
268+
} else if let Some(repository) = repository {
269+
writeln!(buffer, "- Repository: {repository}")?;
255270
}
256271
if let Some(authors) = authors {
257272
writeln!(buffer, "- Authors: {authors}")?;

0 commit comments

Comments
 (0)