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

Accept git remotes with periods in hostname #7386

Merged
merged 5 commits into from
Aug 1, 2021

Conversation

svangordon-fruit
Copy link
Contributor

Description

Fix cloudSourceControlSSHRegex so that it will match git remotes with periods or hyphens in the hostname. However, azureSourceControlSSHRegex does match hostnames with a period. As a result, TryGetVCSInfo will treat these sorts of remotes as Azure source control remotes and drop the first group. This causes updates to have an incorrect "vcs.kind" field. For example, an update with a Git remote of github.foo.acme.com will have a "vcs.kind" field of foo.acme.com. This occurs if a user is using a self-hosted GH enterprise instance.

Fixes # (issue) (No issue has been opened for this)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Further commands available:

  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

CHANGELOG_PENDING.md Show resolved Hide resolved
@@ -53,8 +53,8 @@ const (
// be sure to update its usage elsewhere in the code as well.
// The nolint instruction prevents gometalinter from complaining about the length of the line.
var (
cloudSourceControlSSHRegex = regexp.MustCompile(`git@(?P<host_name>[a-zA-Z]*\.com|[a-zA-Z]*\.org):(?P<owner_and_repo>.*)`) //nolint
azureSourceControlSSHRegex = regexp.MustCompile(`git@([a-zA-Z]+\.)?(?P<host_name>([a-zA-Z]+\.)*[a-zA-Z]*\.com):(v[0-9]{1}/)?(?P<owner_and_repo>.*)`) //nolint
cloudSourceControlSSHRegex = regexp.MustCompile(`git@(?P<host_name>[a-zA-Z.-]*\.com|[a-zA-Z.-]*\.org):(?P<owner_and_repo>[a-zA-Z_-]*/[a-zA-Z_-]*\.git)`) //nolint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity - is the part of this change at the end required? If so - is there any reference you have for the format of this "owner_and_repo" section that suggests the provided new regexps are correct here? For example, can these not contain numbers? Can they not contain other unicode? I fear this might actully prevent this regexp from working on some valid repos?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the regex to allow non-alphanumeric characters in the owner_and_repo group. I'm using this as my reference: https://github.com/jonschlinkert/is-git-url/blob/master/index.js

Generally speaking, there needs to be a way to distinguish between Azure source control and non-Azure source control. Before, the regex was doing that by treating any URL with more than one period in the host name as Azure. With this change, it's treating any URL with with multiple slashes in the owner_and_repo group as Azure.

Could there be an easier way to check if a URL is for Azure source control? Would it be sufficient to check if it contains the substring azure.com?

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Further commands available:

  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

Co-authored-by: Luke Hoban <lukehoban@gmail.com>
@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Further commands available:

  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@justinvp justinvp self-requested a review July 29, 2021 17:26
@justinvp
Copy link
Member

/run-acceptance-tests

@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Further commands available:

  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@justinvp
Copy link
Member

/run-acceptance-tests

@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

1 similar comment
@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

Further commands available:

  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@justinvp
Copy link
Member

/run-acceptance-tests

@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@justinvp justinvp merged commit 29fa23d into pulumi:master Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants