diff --git a/app/components/badge-bitbucket-pipelines.js b/app/components/badge-bitbucket-pipelines.js
new file mode 100644
index 00000000000..d3f6037ed6d
--- /dev/null
+++ b/app/components/badge-bitbucket-pipelines.js
@@ -0,0 +1,16 @@
+import { computed } from '@ember/object';
+import { alias } from '@ember/object/computed';
+import Component from '@ember/component';
+
+export default Component.extend({
+ tagName: 'span',
+ classNames: ['badge'],
+ repository: alias('badge.attributes.repository'),
+ branch: computed('badge.attributes.branch', function() {
+ return encodeURIComponent(this.get('badge.attributes.branch'));
+ }),
+ text: computed('badge.attributes.branch', function() {
+ const branch = this.get('badge.attributes.branch');
+ return `Bitbucket Pipelines build status for the ${branch} branch`;
+ }),
+});
diff --git a/app/templates/components/badge-bitbucket-pipelines.hbs b/app/templates/components/badge-bitbucket-pipelines.hbs
new file mode 100644
index 00000000000..5c1abebe40f
--- /dev/null
+++ b/app/templates/components/badge-bitbucket-pipelines.hbs
@@ -0,0 +1,6 @@
+
+
+
diff --git a/src/models/badge.rs b/src/models/badge.rs
index 7c91cad7921..c6c986b8e78 100644
--- a/src/models/badge.rs
+++ b/src/models/badge.rs
@@ -68,6 +68,10 @@ pub enum Badge {
branch: Option,
service: Option,
},
+ BitbucketPipelines {
+ repository: String,
+ branch: String,
+ },
Maintenance {
status: MaintenanceStatus,
},
diff --git a/src/tests/badge.rs b/src/tests/badge.rs
index 7814d51b5b2..db3ccce24d6 100644
--- a/src/tests/badge.rs
+++ b/src/tests/badge.rs
@@ -23,6 +23,8 @@ struct BadgeRef {
circle_ci_attributes: HashMap,
cirrus_ci: Badge,
cirrus_ci_attributes: HashMap,
+ bitbucket_pipelines: Badge,
+ bitbucket_pipelines_attributes: HashMap,
maintenance: Badge,
maintenance_attributes: HashMap,
}
@@ -144,6 +146,15 @@ fn set_up() -> (BadgeTestCrate, BadgeRef) {
badge_attributes_cirrus_ci.insert(String::from("branch"), String::from("beta"));
badge_attributes_cirrus_ci.insert(String::from("repository"), String::from("rust-lang/rust"));
+ let bitbucket_pipelines = Badge::BitbucketPipelines {
+ repository: String::from("rust-lang/rust"),
+ branch: String::from("beta"),
+ };
+ let mut badge_attributes_bitbucket_pipelines = HashMap::new();
+ badge_attributes_bitbucket_pipelines
+ .insert(String::from("repository"), String::from("rust-lang/rust"));
+ badge_attributes_bitbucket_pipelines.insert(String::from("branch"), String::from("beta"));
+
let maintenance = Badge::Maintenance {
status: MaintenanceStatus::LookingForMaintainer,
};
@@ -175,6 +186,8 @@ fn set_up() -> (BadgeTestCrate, BadgeRef) {
circle_ci_attributes: badge_attributes_circle_ci,
cirrus_ci,
cirrus_ci_attributes: badge_attributes_cirrus_ci,
+ bitbucket_pipelines,
+ bitbucket_pipelines_attributes: badge_attributes_bitbucket_pipelines,
maintenance,
maintenance_attributes,
};
@@ -313,6 +326,20 @@ fn update_add_cirrus_ci() {
assert_eq!(krate.badges(), vec![test_badges.cirrus_ci]);
}
+#[test]
+fn update_add_bitbucket_pipelines() {
+ // Add a Bitbucket Pipelines badge
+ let (krate, test_badges) = set_up();
+
+ let mut badges = HashMap::new();
+ badges.insert(
+ String::from("bitbucket-pipelines"),
+ test_badges.bitbucket_pipelines_attributes,
+ );
+ krate.update(&badges);
+ assert_eq!(krate.badges(), vec![test_badges.bitbucket_pipelines]);
+}
+
#[test]
fn update_add_maintenance() {
// Add a maintenance badge
@@ -587,6 +614,25 @@ fn cirrus_ci_required_keys() {
assert_eq!(krate.badges(), vec![]);
}
+#[test]
+fn bitbucket_pipelines_required_keys() {
+ // Add a Bitbucket Pipelines badge missing a required field
+ let (krate, test_badges) = set_up();
+
+ for required in &["repository", "branch"] {
+ let mut attributes = test_badges.bitbucket_pipelines_attributes.clone();
+ attributes.remove(*required);
+
+ let mut badges = HashMap::new();
+ badges.insert(String::from("bitbucket-pipelines"), attributes);
+
+ let invalid_badges = krate.update(&badges);
+ assert_eq!(invalid_badges.len(), 1);
+ assert_eq!(invalid_badges.first().unwrap(), "bitbucket-pipelines");
+ assert_eq!(krate.badges(), vec![]);
+ }
+}
+
#[test]
fn maintenance_required_keys() {
// Add a maintenance badge missing a required field