From 63899c8bceab96fcd55eb098571b9a6190a476e1 Mon Sep 17 00:00:00 2001 From: Matt Gathu Date: Wed, 13 Sep 2017 09:25:25 +0300 Subject: [PATCH 1/4] Fix Wrong AppVeyor badge this is part of fixing issue #693 :white_check_mark: Add an id field with type Option to the Appveyor badge enum variant :white_check_mark: Add id: alias('badge.attributes.id') to the appveyor badge component :white_check_mark: 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) :white_check_mark: Change the appveyor badge template to use the image-url attribute for the img src instead :white_check_mark: Publish a crate to your local instance that has the URLs dtolnay has listed for serde and manually verify the badge is displayed correctly. --- app/components/badge-appveyor.js | 14 ++++++++++++++ app/templates/components/badge-appveyor.hbs | 2 +- src/badge.rs | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/components/badge-appveyor.js b/app/components/badge-appveyor.js index 407381e9a6f..8cc418fc67b 100644 --- a/app/components/badge-appveyor.js +++ b/app/components/badge-appveyor.js @@ -6,8 +6,22 @@ export default Component.extend({ tagName: 'span', classNames: ['badge'], + id: alias('badge.attributes.id'), repository: alias('badge.attributes.repository'), + imageUrl: computed('badge.attributes.id', function() { + let id = this.get('badge.attributes.id'); + let branch = this.get('branch'); + if (id === undefined || id === null) { + return `https://ci.appveyor.com/api/projects/status/${id}/branch/${branch}?svg=true`; + } else { + let service = this.get('service'); + let repository = this.get('repository'); + + return `https://ci.appveyor.com/api/projects/status/${service}/${repository}?svg=true&branch=${branch}`; + } + }), + branch: computed('badge.attributes.branch', function() { return this.get('badge.attributes.branch') || 'master'; }), diff --git a/app/templates/components/badge-appveyor.hbs b/app/templates/components/badge-appveyor.hbs index c564fabb4ae..a0186e94cca 100644 --- a/app/templates/components/badge-appveyor.hbs +++ b/app/templates/components/badge-appveyor.hbs @@ -1,6 +1,6 @@ {{ text }}, branch: Option, service: Option, }, From be7c820a4c5e7d40493774009fa76284f75af28f Mon Sep 17 00:00:00 2001 From: Matt Gathu Date: Wed, 13 Sep 2017 17:56:32 +0300 Subject: [PATCH 2/4] updated tests added `id` field --- src/tests/badge.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/badge.rs b/src/tests/badge.rs index 47035a3fd10..515be0d7f67 100644 --- a/src/tests/badge.rs +++ b/src/tests/badge.rs @@ -37,6 +37,7 @@ fn set_up() -> (Arc, Crate, BadgeRef) { let appveyor = Badge::Appveyor { service: Some(String::from("github")), + id: None, branch: None, repository: String::from("rust-lang/cargo"), }; From 1b3fb23365037819dde8d922608adeab9eaaee7e Mon Sep 17 00:00:00 2001 From: Matt Gathu Date: Thu, 21 Sep 2017 05:22:32 +0300 Subject: [PATCH 3/4] bug fix: fixed conditional --- app/components/badge-appveyor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/badge-appveyor.js b/app/components/badge-appveyor.js index 8cc418fc67b..09b7126c175 100644 --- a/app/components/badge-appveyor.js +++ b/app/components/badge-appveyor.js @@ -12,7 +12,7 @@ export default Component.extend({ imageUrl: computed('badge.attributes.id', function() { let id = this.get('badge.attributes.id'); let branch = this.get('branch'); - if (id === undefined || id === null) { + if (id !== undefined || id !== null) { return `https://ci.appveyor.com/api/projects/status/${id}/branch/${branch}?svg=true`; } else { let service = this.get('service'); From 24762a43d13be5c79634837706ced9dbaf9296e8 Mon Sep 17 00:00:00 2001 From: Matt Gathu Date: Thu, 21 Sep 2017 05:30:11 +0300 Subject: [PATCH 4/4] bug fix: fixing js conditional --- app/components/badge-appveyor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/badge-appveyor.js b/app/components/badge-appveyor.js index 09b7126c175..d57114569c7 100644 --- a/app/components/badge-appveyor.js +++ b/app/components/badge-appveyor.js @@ -12,7 +12,7 @@ export default Component.extend({ imageUrl: computed('badge.attributes.id', function() { let id = this.get('badge.attributes.id'); let branch = this.get('branch'); - if (id !== undefined || id !== null) { + if (id !== undefined && id !== null) { return `https://ci.appveyor.com/api/projects/status/${id}/branch/${branch}?svg=true`; } else { let service = this.get('service');