-
Notifications
You must be signed in to change notification settings - Fork 18
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
Relax version verification #44
Relax version verification #44
Conversation
I confess I've got a bit lost on how to write a test for this fix (neither figure out where are the tests), but if desired I can write one. |
@caguero friendly ping |
@chapulina @caguero friendly ping |
@caioaamaral , I'll review your PR this week. Thanks for your 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.
I'm a bit hesitant to change the behavior of this option. Specially because we might have situations where two major versions are installed and we want to choose one of them. If we apply this patch we'll lose the ability to do it.
I'd be open to add a new option See my next comment instead.--force-major-version
that ignores the patch number.
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.
Could you also check the discussion on issue #36 please? There's a good suggestion by @chapulina for keeping just the --force-version
argument but allowing multiple values:
- Just a major version. E.g.:
--force-version 9
- Major and minor. E.g.:
--force-version 9.1
- Full version (current behavior). E.g.:
--force-version 9.1.0
This change is expected to behave just like this. I'm splitting the version used as input into different fields (based on the number of '.'), then just those fields will be used when checking against the library version. Ex:
will check only two first fields of version, if they matches then this is the one that will be used. This is achieved by this change on the current implementation: required_version = required_version.split('.')
version = version.split('.')
next unless required_version.zip(version).map {|required, current| required == current}.all? if |
Thanks for the clarification! |
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 did a quick experiment:
caguero@frost:~/workspace/ign-tools/build$ ign topic -l --force-version 9
Traceback (most recent call last):
3: from /usr/bin/ign:236:in `<main>'
2: from /usr/bin/ign:236:in `each_with_index'
1: from /usr/bin/ign:236:in `each'
/usr/bin/ign:238:in `block in <main>': undefined method `split' for #<Array:0x00005576a168c2d0> (NoMethodError)
caguero@frost:~/workspace/ign-tools/build$ ign topic -l --force-version 9.1
Traceback (most recent call last):
3: from /usr/bin/ign:236:in `<main>'
2: from /usr/bin/ign:236:in `each_with_index'
1: from /usr/bin/ign:236:in `each'
/usr/bin/ign:238:in `block in <main>': undefined method `split' for #<Array:0x00005558fd413a60> (NoMethodError)
ign topic -l --force-version 9.1.0
Traceback (most recent call last):
3: from /usr/bin/ign:236:in `<main>'
2: from /usr/bin/ign:236:in `each_with_index'
1: from /usr/bin/ign:236:in `each'
/usr/bin/ign:238:in `block in <main>': undefined method `split' for #<Array:0x00005592b8143ef8> (NoMethodError)
Do you get the same error?
116e8bc
to
edd8b16
Compare
My mistake, sorry for the noise. Just forced push edd8b16 which will solve this problem. Running locally using gazebo command (please ignore the XDG warning, gazebo opened just fine): orise@caioaamaral-Nabuchadnezzar:bin$ ./ign gazebo --force-version 3
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-orise'
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign gazebo --force-version 3.1
Version error: I cannot find this command in version [3.1].
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign gazebo --force-version 3.8
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-orise'
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign gazebo --force-version 3.8.0
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-orise'
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign gazebo --force-version 3.8.1
Version error: I cannot find this command in version [3.8.1].
|
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 for the changes! It works for me as expected when I provide a version that matches my installed library. However it produces an exception when the library is not found, as opposed to show the error message "I cannot find the library...". E.g.:
ign topic -l --force-version 12
Traceback (most recent call last):
3: from /usr/bin/ign:236:in `<main>'
2: from /usr/bin/ign:236:in `each_with_index'
1: from /usr/bin/ign:236:in `each'
/usr/bin/ign:237:in `block in <main>': undefined method `split' for ["12"]:Array (NoMethodError)
ign topic -l --force-version 12.1.2
Traceback (most recent call last):
3: from /usr/bin/ign:236:in `<main>'
2: from /usr/bin/ign:236:in `each_with_index'
1: from /usr/bin/ign:236:in `each'
/usr/bin/ign:237:in `block in <main>': undefined method `split' for ["12", "1", "2"]:Array (NoMethodError)
Strange, I can't reproduce this error: orise@caioaamaral-Nabuchadnezzar:bin$ ./ign topic -l --versions
8.2.0
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign topic -l --force-version 12
Version error: I cannot find this command in version [12].
orise@caioaamaral-Nabuchadnezzar:bin$ ./ign topic -l --force-version 12.1.2
Version error: I cannot find this command in version [12.1.2].
Maybe your binary is missing my last update? |
I think I know what's happening. My guess is that you only have one version of Ignition Transport installed. The problem seems to be here:
Originally, My suggestion is to use a separate local variable for the result of |
Got it, thanks for the clarification. |
Signed-off-by: Caio Amaral <[email protected]>
edd8b16
to
e473b66
Compare
Signed-off-by: Carlos Agüero <[email protected]>
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 works for me! I took the liberty of moving one line outside of the loop. Thanks for the patch!
Signed-off-by: Carlos Agüero <[email protected]>
…ools into fix/version_validation
It's OK, for now we only have a static code checker test. There was a minor issue fixed in ce44884. |
Signed-off-by: Caio Amaral [email protected]
🦟 Bug fix
Fixes #36
Summary
Relax the
--force-version
verification method. Now it's not necessary to specify the fully-qualified version, instead if only the major version is passed, commands will be tested against the major version only.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge