microsoft / sarif-vscode-extension

SARIF Microsoft Visual Studio Code extension
MIT License
110 stars 49 forks source link

Avoid crashing if a git repo has no `origin` #516

Closed aeisenberg closed 1 year ago

aeisenberg commented 1 year ago

If there is no origin, then choose the first remote in the config. If there are no remotes, exit early and send telemetry.

Fixes https://github.com/microsoft/sarif-vscode-extension/issues/515

50Wliu commented 1 year ago

This approach looks like it should work, but you could also consider how the Azure Pipelines extension does it, by looking at HEAD's remote: https://github.com/microsoft/azure-pipelines-vscode/blob/914ccb70757d5c07bf563bac2ce41ba6fa208d7d/src/schema-association-service.ts#L134-L139 (or, alternatively, grabbing the first remote from repo.state.remotes)

aeisenberg commented 1 year ago

Thanks for the suggestion. So, this works if the current branch is connected to an upstream remote? It probably makes more sense to try this first rather than looking for origin.

aeisenberg commented 1 year ago

Thanks, @50Wliu.

@EasyRhinoMSFT are you ok with this?