Skip to content

suborgproperties is matching too many repositories #748

Closed
@grossag

Description

@grossag

Problem Description

I have a suborg file:

suborgproperties:
  - sub-org: horizon-cart

repository:
  topics:
    - horizon-cart

This rule matches 11 repositories in my organization, one of which is euc-vdi/cart. So we end up with this entry in settings.js this.subOrgConfigs:

"cart": {
  "suborgproperties": [{"sub-org":"horizon-cart"}],
  "repository":{"topics":["horizon-cart"]},
  "source":".github/suborgs/horizon-cart.yml"
}

That is correct, but this function implementation does too loose of matching:

  getSubOrgConfig(repoName) {
    if (this.subOrgConfigs) {
      for (const k of Object.keys(this.subOrgConfigs)) {
        const repoPattern = new Glob(k)
        if (repoName.search(repoPattern) >= 0) {
          return this.subOrgConfigs[k]
        }
      }
    }
    return undefined
  }

It causes any repository name starting with cart to match this rule!

Can this be fixed by changing the function to simply be this:

  getSubOrgConfig(repoName) {
    return this.subOrgConfigs[repoName]
  }

Context

Are you using the hosted instance of probot/settings or running your own?

Running our own.

If running your own instance, are you using it with github.com or GitHub Enterprise?

GitHub Enterprise Cloud, so github.com

Version of probot/settings

This issue happens when deploying either a692dbf or 774b2e5

Version of GitHub Enterprise

Using cloud.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions