-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Enriches Azure autolinks on commits: issues and pull requests #3996
base: main
Are you sure you want to change the base?
Conversation
Enriched autolinks work. I'm switching to Home. Do you think we can merge what's done without the rest of #3977? What I'm not sure about is whether it's OK that keep saved |
a7e6cea
to
81408f8
Compare
let linkIntegration = link.provider | ||
? await this.container.integrations.get(link.provider.id as IntegrationId) | ||
: undefined; | ||
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergeibbb !
Here with this new ID converting function we'll need to make sure that other types of enriched autolinks are not broken. What do we have? Jira, GitHub Cloud and Ent, GitLab Cloud and Ent. Anything else to check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases like in Jira, we pass the entire integration in as a provider reference, so remoteProviderIdToIntegrationId
will fail here. I think in the short term here, we can first try treating link.provider.id
as an integration id and try to get the integration from that, and put that in a try/catch so if it fails, then we can try the solution here (try treating it as a remote provider id and convert first before getting the integration).
But in the long term, we need to distinguish, on pull requests, issues, and autolinks, the difference between a remote provider reference and an integration reference. They should be treated separately and put into different properties. If we cannot accomplish that here, we should treat it as a follow-up task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My short term idea would be something like:
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; | |
const integrationId: IntegrationId | undefined = link.provider instanceof Integration ? link.provider.id : isRemoteProviderReference(link.provider) ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; | |
let linkIntegration = integrationId != null ? await this.container.integrations.get(integrationId) : undefined; |
But in long term, we should make sure we never put an Integration into provider
property, reserve that for remote providers, and instead have a separate integration
property or something that is an integration reference.
81408f8
to
55fa0fa
Compare
55fa0fa
to
7e383a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will likely break autolinks for several integrations including Jira, but not really your fault here - we just did a very poor job putting both integrations and remote providers into the same provider
property just because they both match the very loose providerreference
interface.
We should improve on that. I offer a short-term idea and long-term suggestion below, up to you which you think you can get to for this release.
let linkIntegration = link.provider | ||
? await this.container.integrations.get(link.provider.id as IntegrationId) | ||
: undefined; | ||
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases like in Jira, we pass the entire integration in as a provider reference, so remoteProviderIdToIntegrationId
will fail here. I think in the short term here, we can first try treating link.provider.id
as an integration id and try to get the integration from that, and put that in a try/catch so if it fails, then we can try the solution here (try treating it as a remote provider id and convert first before getting the integration).
But in the long term, we need to distinguish, on pull requests, issues, and autolinks, the difference between a remote provider reference and an integration reference. They should be treated separately and put into different properties. If we cannot accomplish that here, we should treat it as a follow-up task.
@@ -1029,13 +1029,8 @@ export class IntegrationService implements Disposable { | |||
} | |||
} | |||
|
|||
export function remoteProviderIdToIntegrationId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid setting the input typing to unknown
here. I know we messed up by treating integrations as remote provider references in several places, but it would be better to work toward addressing that directly rather than loosening the typing here.
let linkIntegration = link.provider | ||
? await this.container.integrations.get(link.provider.id as IntegrationId) | ||
: undefined; | ||
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My short term idea would be something like:
const integrationId = link.provider ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; | |
const integrationId: IntegrationId | undefined = link.provider instanceof Integration ? link.provider.id : isRemoteProviderReference(link.provider) ? remoteProviderIdToIntegrationId(link.provider.id) : undefined; | |
let linkIntegration = integrationId != null ? await this.container.integrations.get(integrationId) : undefined; |
But in long term, we should make sure we never put an Integration into provider
property, reserve that for remote providers, and instead have a separate integration
property or something that is an integration reference.
} | ||
|
||
export interface AzurePullRequest { | ||
repository: unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a type. See https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/get-pull-request?view=azure-devops-rest-7.1#gitpullrequest for all pull request properties and subtypes.
commitId: string; | ||
url: string; | ||
}; | ||
reviewers: unknown[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add and define the appropriate subtypes
return `${baseUrl}/${owner}/${projectName}/_git/${repoName}/pullrequest/${pullRequestId}`; | ||
} | ||
|
||
export interface AzurePullRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing properties here:
autoCompleteSetBy
closedBy
commits
completionOptions
completionQueueTime
forkSource
hasMultipleMergeBases
labels
lastMergeCommit
mergeFailureMessage
mergeFailureType
mergeOptions
mergeStatus
workItemRefs
You can find their descriptions and types here: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/get-pull-request?view=azure-devops-rest-7.1#gitpullrequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't checked but please make sure we have as complete as possible information on Azure issue (work item) typings as well.
Description
#3977
Issues and PRs on a commit
An open issue
A closed issue
An open PR
A closed PR
Checklist
Fixes $XXX -
orCloses #XXX -
prefix to auto-close the issue that your PR addresses