Skip to content

Commit

Permalink
Fix: [GithubCommitActivity] invalid branch error handling (#9258)
Browse files Browse the repository at this point in the history
* Fix error handling of bad branch in [GithubCommitActivity]

When GraphQL response with a bad repo it returns an error indicating the bad repo.
When GraphQL has the currect repo with a bad branch it will null inside the repo object without an error object.
The privouse commits seems to try and use that but due not allowing null in schema it did not work and an error due to bad schema would show insted.

This commit fixes this issue

* Add test for invalid branch in [GithubCommitActivity]

---------

Co-authored-by: jNullj <jNullj@users.noreply.github.com>
  • Loading branch information
jNullj and jNullj committed Jun 14, 2023
1 parent 14892e3 commit 35dfd75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/github/github-commit-activity.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const schema = Joi.object({
history: Joi.object({
totalCount: nonNegativeInteger,
}).required(),
}),
}).allow(null),
}).required(),
}).required(),
}).required()
Expand Down
7 changes: 7 additions & 0 deletions services/github/github-commit-activity.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ t.create('commit activity (repo not found)')
label: 'commit activity',
message: 'repo not found',
})

t.create('commit activity (invalid branch)')
.get('/w/badges/shields/invalidBranchName.json')
.expectBadge({
label: 'commit activity',
message: 'invalid branch',
})

0 comments on commit 35dfd75

Please sign in to comment.