Skip to content

Commit

Permalink
Check maintainers can modify before attempting to update (#101)
Browse files Browse the repository at this point in the history
To avoid messages such as `{"message":"user doesn't have permission to update head repository","documentation_url":"https://docs.github.com/rest/pulls/pulls#update-a-pull-request-branch"}`

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
  • Loading branch information
yardenshoham committed Aug 8, 2023
1 parent 70a19bf commit dfe4f56
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export const needsUpdate = async (prNumber: number) => {
// get the PR and check if its base sha is the same as its base branch
const pr = await fetchPr(prNumber);

// if maintainers can't modify the PR, it doesn't need to be updated
if (!pr.maintainer_can_modify) return false;

// if the PR is not open, it doesn't need to be updated
if (pr.state !== "open") return false;

Expand Down

0 comments on commit dfe4f56

Please sign in to comment.