Skip to content

Commit e70ae13

Browse files
Merge #1111
1111: Fix appveyor badge display and link. r=carols10cents This fixes an issue with appveyor badges where if your repository name included an underscore, the link generated would not work because appveyor urls use dashes. You can now specify an optional `project_name` for the appveyor badge in your `Cargo.toml` ``` [badges] appveyor = { repository = "example/test_crate", service = "github", project_name = "example/test-crate" } ``` If the optional `project_name` attribute is present, we will use that for the link URL, otherwise we default to the required `repository` attribute and replace the underscores with dashes. The reason to provide the `project_name` option is that if you change the repository name appveyor doesn't track the change. Let me know if I missed anything! I did create a test crate and set it up with appveyor to confirm. Closes #587
2 parents cac67b6 + ddc8744 commit e70ae13

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

app/components/badge-appveyor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export default Component.extend({
2626
return this.get('badge.attributes.branch') || 'master';
2727
}),
2828

29+
projectName: computed('badge.attributes.project_name', function() {
30+
return this.get('badge.attributes.project_name') ||
31+
this.get('badge.attributes.repository').replace(/_/g, '-');
32+
}),
33+
2934
service: computed('badge.attributes.service', function() {
3035
return this.get('badge.attributes.service') || 'github';
3136
}),

app/templates/components/badge-appveyor.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a href="https://ci.appveyor.com/project/{{ repository }}">
1+
<a href="https://ci.appveyor.com/project/{{ projectName }}">
22
<img
33
src="{{ imageUrl }}"
44
alt="{{ text }}"

src/badge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum Badge {
1717
repository: String,
1818
id: Option<String>,
1919
branch: Option<String>,
20+
project_name: Option<String>,
2021
service: Option<String>,
2122
},
2223
#[serde(rename = "gitlab")]

src/tests/badge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fn set_up() -> (Arc<App>, Crate, BadgeRef) {
3939
service: Some(String::from("github")),
4040
id: None,
4141
branch: None,
42+
project_name: None,
4243
repository: String::from("rust-lang/cargo"),
4344
};
4445
let mut badge_attributes_appveyor = HashMap::new();

0 commit comments

Comments
 (0)