Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github/pull_author_login as a property for PRs #4535

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions docs/docs/how-to/profile_selectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ Selectors for repositories allow you to filter and manage repositories based on

## Pull request properties set by the GitHub provider

| Field | Description | Type |
|-------------------------|-----------------------------------------|--------|
| `github/pull_url` | The URL of the pull request | string |
| `github/pull_number` | The number of the pull request | string |
| `github/pull_author_id` | The author of the pull request | string |
| `github/repo_name` | The github repo name (e.g. `stacklok`). | string |
| `github/repo_owner` | The github repo owner (e.g. `minder`). | string |
| Field | Description | Type |
|----------------------------|----------------------------------------------------|--------|
| `github/pull_url` | The URL of the pull request | string |
| `github/pull_number` | The number of the pull request | string |
| `github/pull_author_id` | The numerical ID of the author of the pull request | int |
| `github/pull_author_login` | The github login of the author of the pull request | string |
| `github/repo_name` | The github repo name (e.g. `stacklok`). | string |
| `github/repo_owner` | The github repo owner (e.g. `minder`). | string |

## Entity provider selectors

Expand Down
14 changes: 9 additions & 5 deletions internal/providers/github/properties/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
PullPropertyRepoName = "github/repo_name"
// PullPropertyAuthorID is the ID of the author of the pull request
PullPropertyAuthorID = "github/pull_author_id"
// PullPropertyAuthorLogin is the login of the author of the pull request
PullPropertyAuthorLogin = "github/pull_author_login"
// PullPropertyAction is an operational property that represents the action that was taken on the pull request
PullPropertyAction = "github/pull_action"
)
Expand All @@ -61,6 +63,7 @@ var prPropertyDefinitions = []propertyOrigin{
PullPropertyRepoOwner,
PullPropertyRepoName,
PullPropertyAuthorID,
PullPropertyAuthorLogin,
PullPropertyAction,
},
wrapper: getPrWrapper,
Expand Down Expand Up @@ -152,11 +155,12 @@ func getPrWrapper(
// github-specific
PullPropertyURL: prReply.GetHTMLURL(),
// our proto representation uses int64 for the number but GH uses int
PullPropertyNumber: int64(prReply.GetNumber()),
PullPropertySha: prReply.GetHead().GetSHA(),
PullPropertyRepoOwner: owner,
PullPropertyRepoName: name,
PullPropertyAuthorID: prReply.GetUser().GetID(),
PullPropertyNumber: int64(prReply.GetNumber()),
PullPropertySha: prReply.GetHead().GetSHA(),
PullPropertyRepoOwner: owner,
PullPropertyRepoName: name,
PullPropertyAuthorID: prReply.GetUser().GetID(),
PullPropertyAuthorLogin: prReply.GetUser().GetLogin(),
}

return prProps, nil
Expand Down