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

Fixes regexes to accept multipart git repository address. #1655

Merged
merged 5 commits into from
Jun 14, 2020

Conversation

AzaelCicero
Copy link
Contributor

@AzaelCicero AzaelCicero commented Jun 5, 2020

#1651

Adjusted regexes to cover multipart repositories.

Motivation and context

#1651

How has this been tested?

Using reproduction steps from the issue description.

Used single part and multipart addresses in SSH form and HTTPS.

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
    - [ ] I have updated the license header for each file (see an example below)
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

@coveralls
Copy link

coveralls commented Jun 5, 2020

Pull Request Test Coverage Report for Build 5530

  • 5 of 5 (100.0%) changed or added relevant lines in 2 files are covered.
  • 14 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.009%) to 65.695%

Files with Coverage Reduction New Missed Lines %
datumaro/datumaro/components/extractor.py 7 90.7%
datumaro/datumaro/plugins/datumaro_format/converter.py 7 95.37%
Totals Coverage Status
Change from base Build 5502: 0.009%
Covered Lines: 10902
Relevant Lines: 16188

💛 - Coveralls

http_pattern = r"(?:http[s]?://)?" + host_pattern + r"((?:/[a-zA-Z0-9._-]+){2})"
ssh_pattern = r"([a-zA-Z0-9._-]+)@" + host_pattern + r":([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)"
http_pattern = r"(?:http[s]?://)?" + host_pattern + r"((?:/[a-zA-Z0-9._-]+){2,})"
ssh_pattern = r"([a-zA-Z0-9._-]+)@" + host_pattern + r":([a-zA-Z0-9._-]+)((?:/(?:[a-zA-Z0-9._-]+))*)/([a-zA-Z0-9._-]+)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, in the added fragment, the most internal braces can be omitted: /(?:[a-zA-Z0-9._-]+) -> /[a-zA-Z0-9._-]+

Why introduce a new group? Do you have an idea how can this can be used in future?

Thanks for the contribution!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right those braces can be omitted.

Also I reduced complexity of this regex and dropped the additional group. I do not have justification for introduction a new group.

@zhiltsov-max
Copy link
Contributor

@nmanovic, LGTM.

http_pattern = r"(?:http[s]?://)?" + host_pattern + r"((?:/[a-zA-Z0-9._-]+){2})"
ssh_pattern = r"([a-zA-Z0-9._-]+)@" + host_pattern + r":([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)"
http_pattern = r"(?:http[s]?://)?" + host_pattern + r"((?:/[a-zA-Z0-9._-]+){2,})"
ssh_pattern = r"([a-zA-Z0-9._-]+)@" + host_pattern + r":([a-zA-Z0-9._-]+)((?:/[a-zA-Z0-9._-]+)*)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the last * should be +, as with * user@domain.zone:repo is valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good observation.

Copy link
Contributor

@nmanovic nmanovic left a comment

Choose a reason for hiding this comment

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

LGTM

@nmanovic nmanovic merged commit 9320bae into cvat-ai:develop Jun 14, 2020
frndmg pushed a commit to signatrix/cvat that referenced this pull request Aug 5, 2020
* Fixes regexes to accept multipart git repository address.

* Added test case for multi level path.

* Reduced complexity of SSH regex.

* Fixing unit tests.

* Fix SSH formatting.

Co-authored-by: kpawelczyk <kpawelczyk@future-processing.com>
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.

4 participants