github-community-projects / github-community-projects/safe-settings

Checks reporting config differences when there aren't any

Open
#172 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
921
Forks
226
Avg merge
18h 3m
Merged PRs (30d)
14

Description

## Problem Description
When I configure a repo with its existing branch protection config, there are two items which show as changed in the PR check which haven't changed.

### What is actually happening
It looks like the comparison being done here https://github.com/github/safe-settings/blob/main-enterprise/lib/mergeDeep.js#L120-L126 is showing differences for some items when the config should be the same. The two example differences I am seeing are:
------------
From github REST API (target):
```
"enforce_admins": {
"url": "https://api.github.com/repos/Introhive/introhive/branches/master/protection/enforce_admins",
"enabled": false
},
```

Is being compared with config (source):
`"enforce_admins": false,`
-----and-----
From github REST API(target):
```
"required_status_checks": {
"url": "https://api.github.com/repos/Introhive/introhive/branches/master/protection/required_status_checks",
"strict": false,
"contexts": [
"task-list-completed",
"codeclimate"
],
"contexts_url": "https://api.github.com/repos/Introhive/introhive/branches/master/protection/required_status_checks/contexts",
"checks": [
{
"context": "task-list-completed",
"app_id": null
},
{
"context": "codeclimate",
"app_id": null
}
]
```
Is being compared with (source):
```
"required_status_checks": {
"strict": false,
"contexts": [
"task-list-completed",
"codeclimate"
]
}
```
### What is the expected behavior

I would expect the comparisons above to be done in a manner that doesn't indicate there are config changes.

### Error output, if available

```
Branch Protection : introhive : Followings changes will be applied to the branch protection for archived_develop branch = { "additions": { "required_status_checks": { "strict": false } }, "modifications": { "enforce_admins": true } }

Branch Protection : introhive : Followings changes will be applied to the branch protection for master branch = { "additions": { "required_status_checks": { "strict": false }, "restrictions": { "teams": [ "committers", { "name": "Committers", "id": {{REDACTED}}, "node_id": ""id": {{REDACTED}}", "slug": "committers", "description": "Members who can merge PRs into master.", "privacy": "closed", "url": "https://api.github.com/organizations/({REDACTED}}/team/({REDACTED}}", "html_url": "https://github.com/orgs/Introhive/teams/committers", "members_url": "https://api.github.com/organizations/({REDACTED}}/team/({REDACTED}}/members{/member}", "repositories_url": "https://api.github.com/organizations/({REDACTED}}/team/({REDACTED}}/repos", "permission": "pull", "parent": null } ] } }, "modifications": { "enforce_admins": false } }
```

## Context
We would like to be able to validate that these checks to show no changes as we roll safe-settings out for all repositories in our org.

### 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.com

#### Version of probot/settings
"probot": "12.2.0"
safe-settings is synced up to the latest from the `main-enterprise` branch as of today.

#### Version of GitHub Enterprise
N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.