Skip to content

Commit

Permalink
revision_mode = 'scm_folder': Only check if conanfile_path is dirty (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BobIsOnFire authored Jul 19, 2023
1 parent 69301c2 commit d09ae5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conans/client/cmd/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ def _calc_revision(scoped_output, path, manifest, revision_mode):
if revision_mode == "hash":
revision = manifest.summary_hash
else:
f = '-- "."' if revision_mode == "scm_folder" else ""
try:
with chdir(path):
f = '-- "."' if revision_mode == "scm_folder" else ""
revision = check_output_runner(f'git rev-list HEAD -n 1 --full-history {f}').strip()
except Exception as exc:
error_msg = "Cannot detect revision using '{}' mode from repository at " \
"'{}'".format(revision_mode, path)
raise ConanException("{}: {}".format(error_msg, exc))

with chdir(path):
if bool(check_output_runner('git status -s').strip()):
if bool(check_output_runner(f'git status -s {f}').strip()):
raise ConanException("Can't have a dirty repository using revision_mode='scm' and doing"
" 'conan export', please commit the changes and run again.")

Expand Down
5 changes: 5 additions & 0 deletions conans/test/functional/command/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def test_revision_mode_scm_subfolder(self):
t.run(f"export pkgb --name=pkgb --version=0.1")
assert t.exported_recipe_revision() == commit_b

# if pkgb is dirty, we should still be able to correctly create pkga in 'scm_folder' mode
t.save({"pkgb/conanfile.py": conanfile + "\n#new comment"})
t.run(f"export pkga --name=pkga --version=0.1")
assert t.exported_recipe_revision() == commit

def test_auto_revision_without_commits(self):
"""If we have a repo but without commits, it has to fail when the revision_mode=scm"""
t = TestClient()
Expand Down

0 comments on commit d09ae5b

Please sign in to comment.