Skip to content

Commit ba37a57

Browse files
Merge #1050
1050: Fix Wrong AppVeyor badge r=carols10cents this is part of fixing issue #693 - [x] Add an id field with type Option<String> to the Appveyor badge enum variant - [x] Add id: alias('badge.attributes.id') to the appveyor badge component - [x] Add an image-url attribute, computed from the id to the appveyor badge component that checks to see if id is defined. (I've used `imageUrl` as attribute) - [x] Change the appveyor badge template to use the image-url attribute for the img src instead - [x] Publish a crate to your local instance that has the URLs dtolnay has listed for serde and manually verify the badge is displayed correctly. - [x] Send a pull request to cargo to update the badge documentation to indicate you can specify the appveyor project id if you want to use that instead. (_https://github.com/rust-lang/cargo/pull/4489_)
2 parents 76d15c1 + 24762a4 commit ba37a57

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

app/components/badge-appveyor.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@ export default Component.extend({
66
tagName: 'span',
77
classNames: ['badge'],
88

9+
id: alias('badge.attributes.id'),
910
repository: alias('badge.attributes.repository'),
1011

12+
imageUrl: computed('badge.attributes.id', function() {
13+
let id = this.get('badge.attributes.id');
14+
let branch = this.get('branch');
15+
if (id !== undefined && id !== null) {
16+
return `https://ci.appveyor.com/api/projects/status/${id}/branch/${branch}?svg=true`;
17+
} else {
18+
let service = this.get('service');
19+
let repository = this.get('repository');
20+
21+
return `https://ci.appveyor.com/api/projects/status/${service}/${repository}?svg=true&branch=${branch}`;
22+
}
23+
}),
24+
1125
branch: computed('badge.attributes.branch', function() {
1226
return this.get('badge.attributes.branch') || 'master';
1327
}),

app/templates/components/badge-appveyor.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<a href="https://ci.appveyor.com/project/{{ repository }}">
22
<img
3-
src="https://ci.appveyor.com/api/projects/status/{{ service }}/{{ repository }}?svg=true&branch={{ branch }}"
3+
src="{{ imageUrl }}"
44
alt="{{ text }}"
55
width="106"
66
height="20"

src/badge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub enum Badge {
1515
},
1616
Appveyor {
1717
repository: String,
18+
id: Option<String>,
1819
branch: Option<String>,
1920
service: Option<String>,
2021
},

src/tests/badge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn set_up() -> (Arc<App>, Crate, BadgeRef) {
3737

3838
let appveyor = Badge::Appveyor {
3939
service: Some(String::from("github")),
40+
id: None,
4041
branch: None,
4142
repository: String::from("rust-lang/cargo"),
4243
};

0 commit comments

Comments
 (0)