intuit / intuit/auto

pr-status doesn't work when we don't pass the optional --pr parameter

Open
#2,507 0 comments 1 reaction 2 assignees Claimed by @adierkens View on GitHub
bug
Dominant language
TypeScript
Stars
2.5k
Forks
221
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

the `pr-status` command has an optional parameter `--pr`. This command was design to only use the PR number when we don't pass a `--sha` parameter. Even if we don't pass the `--sha` and `--pr` parameters, the command was designed to obtain the `sha` from the HEAD of the current branch.

The code has a try-catch to prevent auto from throwing an error when the PR number is not available. But this try-catch is not working because the `getPrNumber()` function calls `process.exit(1)`. The `try-catch` is not able to stop that.

https://github.com/intuit/auto/blob/27b93e34871e1fa99e9807d17e0854d6bc22f34d/packages/core/src/auto.ts#L1831

https://github.com/intuit/auto/blob/27b93e34871e1fa99e9807d17e0854d6bc22f34d/packages/core/src/auto.ts#L955-L959

**To Reproduce**

Try to create a commit status during the `merge_group` event (merge queue) (or even the `push` event). This might be needed when `Auto PR Check` is a required status check that is set by `auto pr-check` in the `pull_request` event. Since it's a required status check, for repos using the merge queue, it also needs to be set during `merge_group` event (merge queue). In this case, there's no PR number. It should be enough using `--sha ${{ github.sha }}`.

```
auto pr-status --url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --context "Auto PR Check" --sha ${{ github.sha }} --state success --description "PR labels validated in original PR"
```

**Expected behavior**

`pr-status` should work even if we don't pass the `--pr` parameter.

**Screenshots**

**Environment information:**

```txt
ℹ info ENV: {
isCi: true,
name: 'GitHub Actions',
service: 'github',
commit: 'dfdf9d',
build: '12',
isPr: false,
branch: 'gh-readonly-queue/main/pr-123-efbde6',
prBranch: undefined,
slug: '/',
root: '/home/'
}

```

**Additional context**

N/A

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.