-
Notifications
You must be signed in to change notification settings - Fork 40
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
Changed order of the url check. #100
Conversation
src/rosdistro/rosdistro.py
Outdated
url = repo.url | ||
release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version) | ||
tail = '/{0}/package.xml'.format(release_tag) | ||
url = url.replace('.git', tail) | ||
url = url.replace('git://', 'https://') |
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.
Has this been removed intentionally ? If yes, why did this become unnecessary ?
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.
It was not intentional. Good catch. Oddly, it works, but... I haven't tried it for indigo yet. One moment.
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.
It makes sense to check the url of the new format first. It has been quite a while since this logic has been introduced (838b119) and by now the new format is the standard. So 👍 from me to invert the logic.
Instead of shuffling the logic I would suggest to just swap the lines 203 and 214.
My previous comment still applies: why shuffle all this code? Isn't it enough to swap these two lines: rosdistro/src/rosdistro/rosdistro.py Line 203 in d5f6f03
rosdistro/src/rosdistro/rosdistro.py Line 214 in d5f6f03
|
src/rosdistro/rosdistro.py
Outdated
release_tag = 'release/{0}/{1}'.format(self.name, upstream_version) | ||
url = url.replace('.git', '/{0}/package.xml'.format(release_tag)) | ||
url = url.replace('git://', 'https://') | ||
url = url.replace('https://', 'https://raw.') |
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.
This seems like a duplication of the more robust logic which is here:
Can we consolidate?
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.
That would be a much better solution, yes. Let me do that.
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.
Please keep the actual change swapping the order or urls fetched separate from code refactoring (like deduplicating logic). At least in separate commits - maybe even in separate PRs.
Upon further inspection, it appears that, in the function you linked, they call https://github.com/ros-infrastructure/rosdistro/blob/master/src/rosdistro/rosdistro.py#L238 There seems to be some redundancy here in fetching the |
In that case you'd want to use the CachedManifestProvider, as in: rosdistro/src/rosdistro/__init__.py Lines 141 to 144 in d5f6f03
However, looks like it might be some crazy legacy-supporting side logic, so let's wait for a verdict from @dirk-thomas about the right path forward before you try to change too much. |
Will do. I was mistaken by the structure a little -- I will play around with it some, then bother dirk in a few. |
6141662
to
fc89de1
Compare
@dirk-thomas Should be the correct format now. @mikepurvis After digging through things for a good while, I've determined that the amount of refactoring needed to avoid duplication of this logic reaches beyond the bounds of this pull request. |
src/rosdistro/rosdistro.py
Outdated
upstream_version = repo.version.split('-')[0] | ||
release_tag = 'release/{0}/{1}'.format(self.name, upstream_version) | ||
url = url.replace('.git', '/{0}/package.xml'.format(release_tag)) | ||
# release_tag = get_release_tag(self.name) |
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.
This line should be removed.
src/rosdistro/rosdistro.py
Outdated
try: | ||
try: | ||
release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version) | ||
url = url.format(release_tag) |
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.
Before format
was only called on strings defined in the source code. Now format
is being called on a user provided string which might contain characters like {}
and therefore result in problems. Therefore please only use format
on strings defined in the code directly.
Same below in line 218:
url = url.format(release_tag)
src/rosdistro/rosdistro.py
Outdated
package_xml = urlopen(url).read() | ||
except Exception as e: | ||
except Exception as e: |
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.
Please remove the trailing whitespace.
src/rosdistro/rosdistro.py
Outdated
try: | ||
try: | ||
release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version) |
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.
This line as well as the next one shouldn't be in the try
/ except
block.
@dirk-thomas I restructured the logic a little to fix it. Should be good now. |
src/rosdistro/rosdistro.py
Outdated
upstream_version = repo.version.split('-')[0] | ||
release_tag = 'release/{0}/{1}'.format(self.name, upstream_version) | ||
url = url.replace('.git', '/{0}/package.xml'.format(release_tag)) | ||
tail = 'release/{0}/{1}/{2}/package.xml'.format(rosdistro, self.name, repo.version) |
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 would suggest to keep the variable name as release_tag
since the string is the release tag.
src/rosdistro/rosdistro.py
Outdated
url = url.replace('https://', 'https://raw.') | ||
info("Trying to read from url '{0}' instead".format(url)) | ||
upstream_version = repo.version.split('-')[0] | ||
legacy_tail = 'release/{0}/{1}/package.xml'.format(self.name, upstream_version) |
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 would suggest to rename the variable to legacy_release_tag
.
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.
@dirk-thomas you got it
The previous state seem to lack the leading slash in the replacement: see 1c6eb29#diff-65e54a8cd0a3220cd2b0b2091bd58708R202 Anyway I added two commits to this PR to minimize the changes and keep the semantic of the variables ( |
@dirk-thomas All is working as expected! |
Thanks! |
Fixes #99