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

Allow fetching repos from url #123

Closed
wants to merge 3 commits into from
Closed

Allow fetching repos from url #123

wants to merge 3 commits into from

Conversation

rotu
Copy link
Contributor

@rotu rotu commented Apr 17, 2020

If a URL is passed to --input, we fetch the resource. This removes the need for curl or wget in many cases.

Copy link
Owner

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

Beside the inline comments please also add tests covering the new feature.

@@ -33,12 +38,20 @@ def __init__(self, args, url, version=None, recursive=False):
self.recursive = recursive


def file_or_url_type(x):
try:
return urlopen(x)
Copy link
Owner

Choose a reason for hiding this comment

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

In case the URL parsing raises an exception a stacktrace is shown which isn't user friendly. Please catch the relevant exceptions and print a single line error message.

def get_parser():
parser = argparse.ArgumentParser(
description='Import the list of repositories', prog='vcs import')
group = parser.add_argument_group('"import" command parameters')
group.add_argument(
'--input', type=argparse.FileType('r'), default=sys.stdin)
'--input', type=file_or_url_type, default='-',
Copy link
Owner

Choose a reason for hiding this comment

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

The loading of the URL should happen and arg parsing since it could take an arbitrary amount of time. Considering the case that e.g. completion is being computed using parse_known_args, Please move it loading of the URL post arg parsing.

Copy link
Owner

Choose a reason for hiding this comment

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

Unrelated question: why does the patch change the default argument?

Copy link
Contributor Author

@rotu rotu Apr 17, 2020

Choose a reason for hiding this comment

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

Because argparse formats it weird otherwise in vcs --help. - is another name for stdin.

@rotu
Copy link
Contributor Author

rotu commented Apr 17, 2020

Beside the inline comments please also add tests covering the new feature.

You have previously objected when I've added tests and features in the same PR. Would you still like me to add tests?

@dirk-thomas
Copy link
Owner

You have previously objected when I've added tests and features in the same PR.

I doubt that I have ever made such a statement - to not add tests for the feature being added in the PR.

Would you still like me to add tests?

Yes.

@rotu rotu marked this pull request as draft April 17, 2020 20:37
@rotu rotu mentioned this pull request Apr 20, 2020
@dirk-thomas
Copy link
Owner

@rotu Since it has been a month I just wanted to check if you are planning to follow up on this ticket or if not close the ticket for now.

@rotu
Copy link
Contributor Author

rotu commented May 21, 2020

It's still a draft since the test coverage is not comprehensive and not a high priority right now. Due to personal stuff, I'm not sure if I'll be able to wrap this up any time soon. I'm sorry - I really want to give this the attention it deserves. If you want to pick up where I left off, I wouldn't mind.

@dirk-thomas
Copy link
Owner

Superseded by #155.

@dirk-thomas dirk-thomas closed this Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants