Skip to content

Commit

Permalink
fix eslint casing errors for environments
Browse files Browse the repository at this point in the history
This was done manually as no autofix was available.
  • Loading branch information
Gramatus committed Sep 15, 2024
1 parent 2bc6506 commit d9083f5
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 102 deletions.
46 changes: 23 additions & 23 deletions lib/plugins/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = class Environments extends Diffable {
repo: this.repo.repo
})

const environments_mapped = []
const environmentsMapped = []

for (const environment of environments) {
const mapped = {
Expand Down Expand Up @@ -63,11 +63,11 @@ module.exports = class Environments extends Diffable {
id: rule.id
}))
}
environments_mapped.push(mapped)
environmentsMapped.push(mapped)
// console.log(mapped);
}

return environments_mapped
return environmentsMapped
}

comparator (existing, attrs) {
Expand All @@ -82,46 +82,46 @@ module.exports = class Environments extends Diffable {
if (!attrs.variables) attrs.variables = []
if (!attrs.deployment_protection_rules) attrs.deployment_protection_rules = []

const wait_timer = existing.wait_timer !== attrs.wait_timer
const prevent_self_review = existing.prevent_self_review !== attrs.prevent_self_review
const waitTimer = existing.wait_timer !== attrs.wait_timer
const preventSelfReview = existing.prevent_self_review !== attrs.prevent_self_review
const reviewers = JSON.stringify(existing.reviewers.sort((x1, x2) => x1.id - x2.id)) !== JSON.stringify(attrs.reviewers.sort((x1, x2) => x1.id - x2.id))

let existing_custom_branch_policies = existing.deployment_branch_policy === null ? null : existing.deployment_branch_policy.custom_branch_policies
if (typeof (existing_custom_branch_policies) === 'object' && existing_custom_branch_policies !== null) {
existing_custom_branch_policies = existing_custom_branch_policies.sort()
let existingCustomBranchPolicies = existing.deployment_branch_policy === null ? null : existing.deployment_branch_policy.custom_branch_policies
if (typeof (existingCustomBranchPolicies) === 'object' && existingCustomBranchPolicies !== null) {
existingCustomBranchPolicies = existingCustomBranchPolicies.sort()
}
let attrs_custom_branch_policies = attrs.deployment_branch_policy === null ? null : attrs.deployment_branch_policy.custom_branch_policies
if (typeof (attrs_custom_branch_policies) === 'object' && attrs_custom_branch_policies !== null) {
attrs_custom_branch_policies = attrs_custom_branch_policies.sort()
let attrsCustomBranchPolicies = attrs.deployment_branch_policy === null ? null : attrs.deployment_branch_policy.custom_branch_policies
if (typeof (attrsCustomBranchPolicies) === 'object' && attrsCustomBranchPolicies !== null) {
attrsCustomBranchPolicies = attrsCustomBranchPolicies.sort()
}
let deployment_branch_policy
let deploymentBranchPolicy
if (existing.deployment_branch_policy === attrs.deployment_branch_policy) {
deployment_branch_policy = false
deploymentBranchPolicy = false
} else {
deployment_branch_policy = (
deploymentBranchPolicy = (
(existing.deployment_branch_policy === null && attrs.deployment_branch_policy !== null) ||
(existing.deployment_branch_policy !== null && attrs.deployment_branch_policy === null) ||
(existing.deployment_branch_policy.protected_branches !== attrs.deployment_branch_policy.protected_branches) ||
(JSON.stringify(existing_custom_branch_policies) !== JSON.stringify(attrs_custom_branch_policies))
(JSON.stringify(existingCustomBranchPolicies) !== JSON.stringify(attrsCustomBranchPolicies))
)
}

const variables = JSON.stringify(existing.variables.sort((x1, x2) => x1.name - x2.name)) !== JSON.stringify(attrs.variables.sort((x1, x2) => x1.name - x2.name))
const deployment_protection_rules = JSON.stringify(existing.deployment_protection_rules.map(x => ({ app_id: x.app_id })).sort((x1, x2) => x1.app_id - x2.app_id)) !== JSON.stringify(attrs.deployment_protection_rules.map(x => ({ app_id: x.app_id })).sort((x1, x2) => x1.app_id - x2.app_id))
const deploymentProtectionRules = JSON.stringify(existing.deployment_protection_rules.map(x => ({ app_id: x.app_id })).sort((x1, x2) => x1.app_id - x2.app_id)) !== JSON.stringify(attrs.deployment_protection_rules.map(x => ({ app_id: x.app_id })).sort((x1, x2) => x1.app_id - x2.app_id))

return { wait_timer, prevent_self_review, reviewers, deployment_branch_policy, variables, deployment_protection_rules }
return { waitTimer, preventSelfReview, reviewers, deploymentBranchPolicy, variables, deploymentProtectionRules }
}

changed (existing, attrs) {
const { wait_timer, prevent_self_review, reviewers, deployment_branch_policy, variables, deployment_protection_rules } = this.getChanged(existing, attrs)
const { waitTimer, preventSelfReview, reviewers, deploymentBranchPolicy, variables, deploymentProtectionRules } = this.getChanged(existing, attrs)

return wait_timer || prevent_self_review || reviewers || deployment_branch_policy || variables || deployment_protection_rules
return waitTimer || preventSelfReview || reviewers || deploymentBranchPolicy || variables || deploymentProtectionRules
}

async update (existing, attrs) {
const { wait_timer, prevent_self_review, reviewers, deployment_branch_policy, variables, deployment_protection_rules } = this.getChanged(existing, attrs)
const { waitTimer, preventSelfReview, reviewers, deploymentBranchPolicy, variables, deploymentProtectionRules } = this.getChanged(existing, attrs)

if (wait_timer || prevent_self_review || reviewers || deployment_branch_policy) {
if (waitTimer || preventSelfReview || reviewers || deploymentBranchPolicy) {
await this.github.request('PUT /repos/:org/:repo/environments/:environment_name', {
org: this.repo.owner,
repo: this.repo.repo,
Expand All @@ -138,7 +138,7 @@ module.exports = class Environments extends Diffable {
})
}

if (deployment_branch_policy && attrs.deployment_branch_policy && attrs.deployment_branch_policy.custom_branch_policies) {
if (deploymentBranchPolicy && attrs.deployment_branch_policy && attrs.deployment_branch_policy.custom_branch_policies) {
const existingPolicies = (await this.github.request('GET /repos/:org/:repo/environments/:environment_name/deployment-branch-policies', {
org: this.repo.owner,
repo: this.repo.repo,
Expand Down Expand Up @@ -201,7 +201,7 @@ module.exports = class Environments extends Diffable {
}
}

if (deployment_protection_rules) {
if (deploymentProtectionRules) {
const existingRules = [...existing.deployment_protection_rules]

for (const rule of attrs.deployment_protection_rules) {
Expand Down
Loading

0 comments on commit d9083f5

Please sign in to comment.