Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions conan/internal/api/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,21 @@ def _calc_revision(scoped_output, path, manifest, revision_mode, conanfile):
if revision_mode == "hash":
revision = manifest.summary_hash
else:
repository = (revision_mode == "scm")
# Exception to the rule that tools should only be used in recipes, this Git helper is ok
excluded = getattr(conanfile, "revision_mode_excluded", None)
git = Git(conanfile, folder=path, excluded=excluded)
try:
revision = git.get_commit(repository=(revision_mode == "scm"))
revision = git.get_commit(repository=repository)
except Exception as exc:
error_msg = "Cannot detect revision using '{}' mode from repository at " \
"'{}'".format(revision_mode, path)
raise ConanException("{}: {}".format(error_msg, exc))

if git.is_dirty():
raise ConanException("Can't have a dirty repository using revision_mode='scm' and doing"
if git.is_dirty(repository=repository):
Copy link
Member

Choose a reason for hiding this comment

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

I have some concerns that this might be breaking for users that have the repository dirty with some temp files outside of the conanfile subfolder, and suddenly this stops working. Having those temporary files in the root repo wouldn't be a big problem in most cases, isn't it?

Is this check really that important to protect at the repository level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it isn't, at least not for me and not now.
But what is the use-case of using the whole git repo for the ref (as opposed to scm_folder), and having dirty stuff lying around then?

I saw this inconsistency during investigation of different methods for revision_mode and git source retrieval.
If it shouldn't be changed, we should at least add a comment to the source code, that it's the way it currently is on purpose and a link to that PR.

raise ConanException("Can't have a dirty repository using revision_mode='scm'/'scm_folder' and doing"
" 'conan export', please commit the changes and run again, or "
"use 'git_excluded = []' attribute")
"use 'revision_mode_excluded' config")

scoped_output.info("Using git commit as the recipe revision: %s" % revision)

Expand Down