Skip to content

Commit 5fc8ac7

Browse files
committed
Auto merge of #6096 - mathstuf:export-repository-info, r=alexcrichton
build: export repository information The repository string is made available via the `CARGO_PKG_REPOSITORY` environment variable similar to other metadata.
2 parents 9801c50 + ae6b2f6 commit 5fc8ac7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/cargo/core/compiler/compilation.rs

+4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ impl<'cfg> Compilation<'cfg> {
236236
"CARGO_PKG_HOMEPAGE",
237237
metadata.homepage.as_ref().unwrap_or(&String::new()),
238238
)
239+
.env(
240+
"CARGO_PKG_REPOSITORY",
241+
metadata.repository.as_ref().unwrap_or(&String::new()),
242+
)
239243
.env("CARGO_PKG_AUTHORS", &pkg.authors().join(":"))
240244
.cwd(pkg.root());
241245
Ok(cmd)

src/doc/src/reference/environment-variables.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ let version = env!("CARGO_PKG_VERSION");
6161
* `CARGO_PKG_VERSION_PRE` - The pre-release version of your package.
6262
* `CARGO_PKG_AUTHORS` - Colon separated list of authors from the manifest of your package.
6363
* `CARGO_PKG_NAME` - The name of your package.
64-
* `CARGO_PKG_DESCRIPTION` - The description of your package.
65-
* `CARGO_PKG_HOMEPAGE` - The home page of your package.
64+
* `CARGO_PKG_DESCRIPTION` - The description from the manifest of your package.
65+
* `CARGO_PKG_HOMEPAGE` - The home page from the manifest of your package.
66+
* `CARGO_PKG_REPOSITORY` - The repository from the manifest of your package.
6667
* `OUT_DIR` - If the package has a build script, this is set to the folder where the build
6768
script should place its output. See below for more information.
6869

tests/testsuite/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ fn crate_env_vars() {
13681368
version = "0.5.1-alpha.1"
13691369
description = "This is foo"
13701370
homepage = "http://example.com"
1371+
repository = "http://example.com/repo.git"
13711372
authors = ["wycats@example.com"]
13721373
"#,
13731374
).file(
@@ -1384,6 +1385,7 @@ fn crate_env_vars() {
13841385
static CARGO_MANIFEST_DIR: &'static str = env!("CARGO_MANIFEST_DIR");
13851386
static PKG_NAME: &'static str = env!("CARGO_PKG_NAME");
13861387
static HOMEPAGE: &'static str = env!("CARGO_PKG_HOMEPAGE");
1388+
static REPOSITORY: &'static str = env!("CARGO_PKG_REPOSITORY");
13871389
static DESCRIPTION: &'static str = env!("CARGO_PKG_DESCRIPTION");
13881390
13891391
fn main() {
@@ -1394,6 +1396,7 @@ fn crate_env_vars() {
13941396
println!("{}", s);
13951397
assert_eq!("foo", PKG_NAME);
13961398
assert_eq!("http://example.com", HOMEPAGE);
1399+
assert_eq!("http://example.com/repo.git", REPOSITORY);
13971400
assert_eq!("This is foo", DESCRIPTION);
13981401
let s = format!("{}.{}.{}-{}", VERSION_MAJOR,
13991402
VERSION_MINOR, VERSION_PATCH, VERSION_PRE);

0 commit comments

Comments
 (0)