-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
Pull Request Test Coverage Report for Build 5530
💛 - Coveralls |
cvat/apps/git/git.py
Outdated
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._-]+)" |
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.
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!
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.
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.
@nmanovic, LGTM. |
cvat/apps/git/git.py
Outdated
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._-]+)*)" |
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.
Looks like the last *
should be +
, as with *
user@domain.zone:repo
is valid.
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.
Thanks, good observation.
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.
LGTM
* 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>
#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
develop
branch- [ ] I have added description of my changes into CHANGELOG file- [ ] I have updated the documentation accordingly- [ ] I have increased versions of npm packages if it is necessary (cvat-canvas,cvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
- [ ] I have updated the license header for each file (see an example below)