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
Auto origin deduced as none if no origin #7048
Auto origin deduced as none if no origin #7048
Conversation
e41b1bf
to
56e619a
Compare
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 is looking good thank you!
Asking for another review, to check too about the minor details (might be subjective opinion, so I prefer to have someone else review).
Assigning this to 1.26, it is almost ready
conans/client/cmd/export.py
Outdated
if scm.is_local_repository(): | ||
output.warn("Repo origin looks like a local path: %s" % origin) | ||
output.success("Repo origin deduced by 'auto': %s" % origin) | ||
if origin is None: | ||
output.warn("origin is None, upload' command will prevent uploading recipes with None values in these fields.") |
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 it would be better to keep scm_data.url = "auto"
and not assign it None
. It is more symmetric to the scm.revision
behavior.
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.
And if necessary to change output messages, check for the "auto" string.
@@ -127,8 +127,9 @@ def test_auto_git(self): | |||
conanfile = base_git.format(directory="None", url=_quoted("auto"), revision="auto") | |||
self.client.save({"conanfile.py": conanfile, "myfile.txt": "My file is copied"}) | |||
create_local_git_repo(folder=self.client.current_folder) | |||
self.client.run("export . user/channel", assert_error=True) | |||
self.assertIn("Repo origin cannot be deduced", self.client.out) | |||
self.client.run("export . user/channel", assert_error=False) |
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.
Do not use assert_error=False
, it is the default, can be omitted.
As I commented on the issue, I would prefer to keep |
@jgsogo We did not prevent user to set |
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.
Great job, thanks!
@@ -295,8 +295,8 @@ def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote, remo | |||
if policy != UPLOAD_POLICY_FORCE: | |||
# Check SCM data for auto fields | |||
if hasattr(conanfile, "scm") and ( | |||
conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto"): | |||
raise ConanException("The recipe has 'scm.url' or 'scm.revision' with 'auto' " | |||
conanfile.scm.get("url") == None or conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto"): |
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.
Having a second thought, if there are users that are doing url=None
, and now we start to block them: will they be surprised? Why are they doing this? The problem is that such information is not reproducible for conan builds (but the revision is there, they might use it in CI? Maybe with conan inspect
is possible to read the revision
and the URL is hardcoded in the CI?
Let's make sure we are not breaking other users without a clear value/alternative or without declaring it a bug.
Asking for @jgsogo feedback.
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.
when the url=None, it is not possible to upload anyway.
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.
If we want to cover in this PR the use-case where the SCM won't work because url
is None
, then we should cover other scenarios too: IMHO, if type
is None
or revision
is None
we should probably fail to upload the recipe.
This comment has been minimized.
This comment has been minimized.
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, consider my previous comment before moving forward, I'm open to alternatives, maybe I'm missing something.
I am not sure what you mean. It seems the proposed behavior is good:
Can you please clarify what you mean? |
This comment has been minimized.
This comment has been minimized.
I need to revisit this PR taking into account that it tries to handle another use case too, when the URL is declared as |
|
||
if scm_data.url is None: | ||
output.warn( | ||
"origin is None, upload' command will prevent uploading recipes with None values in these fields.") |
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 just change the lines around the exception and return without substituting the revision
(no modification, like we do when the repo is not pristine):
if not origin:
output.warn("Repo origin cannot be deduced, 'auto' fields won't be replaced."
" 'conan upload' command will prevent uploading recipes with 'auto'"
" values in these fields.")
local_src_path = scm.get_local_path_to_url(origin)
return scm_data, local_src_path
No need to modify is_local_repository
or get_remote_url
functions.
@@ -295,8 +295,8 @@ def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote, remo | |||
if policy != UPLOAD_POLICY_FORCE: | |||
# Check SCM data for auto fields | |||
if hasattr(conanfile, "scm") and ( | |||
conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto"): | |||
raise ConanException("The recipe has 'scm.url' or 'scm.revision' with 'auto' " | |||
conanfile.scm.get("url") == None or conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto"): |
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.
If we want to cover in this PR the use-case where the SCM won't work because url
is None
, then we should cover other scenarios too: IMHO, if type
is None
or revision
is None
we should probably fail to upload the recipe.
As this PR seems fine, lets merge it and we can contribute the remaining checks ("type=None, revision=None") later. |
Changelog: Fix: Do not modify
scm
attribute when theorigin
remote cannot be deduced.Changelog: Bugfix: Do not allow uploading packages with missing information in the
scm
attribute.Docs: omit
closes #7033
Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.