Skip to content

Commit 63899c8

Browse files
committed
Fix Wrong AppVeyor badge
this is part of fixing issue #693 ✅ Add an id field with type Option<String> to the Appveyor badge enum variant ✅ Add id: alias('badge.attributes.id') to the appveyor badge component ✅ 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) ✅ Change the appveyor badge template to use the image-url attribute for the img src instead ✅ Publish a crate to your local instance that has the URLs dtolnay has listed for serde and manually verify the badge is displayed correctly.
1 parent be1429c commit 63899c8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-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
},

0 commit comments

Comments
 (0)