Skip to content

Let conan config install walk the fs tree looking for a .conanignore#18170

Merged
franramirez688 merged 12 commits into
conan-io:develop2from
AbrilRBS:ar/conanignore-walk-tree
May 7, 2025
Merged

Let conan config install walk the fs tree looking for a .conanignore#18170
franramirez688 merged 12 commits into
conan-io:develop2from
AbrilRBS:ar/conanignore-walk-tree

Conversation

@AbrilRBS

@AbrilRBS AbrilRBS commented Apr 24, 2025

Copy link
Copy Markdown
Member

Changelog: Bugfix: Let conan config install walk the fs tree looking for a .conanignore.
Docs: Omit

I was trying to install a specific command from conan-extensions and realized that the readme next to it was being installed too.

This PR is a draft because I'm not quite sure of the implications of walking the tree in all contexts where this could be called:

  • Should this stop earlier?
  • Should we even do this walk?

@AbrilRBS AbrilRBS requested a review from Copilot April 24, 2025 09:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to have "conan config install" search up the file system for a .conanignore file, preventing unwanted files from being installed.

  • Introduces tests to verify behavior when a .conanignore is present or absent.
  • Implements a new helper function that walks the directory tree to locate a .conanignore file.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/integration/command/config_test.py Added tests to validate that the .conanignore is correctly applied.
conan/internal/api/config/config_installer.py Added the recursive lookup helper (_find_conaningore) and updated folder processing to use it.
Comments suppressed due to low confidence (2)

test/integration/command/config_test.py:168

  • [nitpick] The test function name 'test_config_install_conanignore_march_directories' appears to contain a typo. Consider renaming it to something like 'test_config_install_conanignore_match_directories' for clarity.
def test_config_install_conanignore_march_directories(has_conanignore, folder):

conan/internal/api/config/config_installer.py:131

  • The function name '_find_conaningore' seems to be misspelled; consider renaming it to '_find_conanignore' to accurately reflect its purpose and align with established naming conventions.
def _find_conaningore(folder):

Comment thread conan/internal/api/config/config_installer.py Outdated
@AbrilRBS AbrilRBS marked this pull request as ready for review April 28, 2025 10:26
@AbrilRBS AbrilRBS added this to the 2.17.0 milestone Apr 28, 2025
@AbrilRBS AbrilRBS force-pushed the ar/conanignore-walk-tree branch from 0ae8eb3 to e0e1495 Compare April 29, 2025 09:33
Comment thread conan/internal/api/config/config_installer.py Outdated
@franramirez688

Copy link
Copy Markdown
Contributor

@AbrilRBS Besides the comment, there are conflicts pending 🙏

@AbrilRBS AbrilRBS force-pushed the ar/conanignore-walk-tree branch from eab8cc9 to 399d27a Compare May 5, 2025 18:14
Comment thread conan/internal/api/config/config_installer.py Outdated
@AbrilRBS AbrilRBS requested a review from Copilot May 7, 2025 09:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the “conan config install” command by updating the file search logic so that a .conanignore file can be located by walking up the file system tree. Key changes include:

  • Adding a new helper function (find_file_walk_up) to traverse parent directories.
  • Refactoring tests in both unit and integration suites to verify the new upward search behavior.
  • Updating the config installer to use the new helper function in determining the .conanignore file.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/unittests/paths/user_home_test.py Refactored tests into classes and added tests for the new helper function.
test/integration/command/config_test.py Added parametrized tests to validate the .conanignore behavior during config install.
conan/internal/paths.py Introduced find_file_walk_up and updated get_conan_user_home to use it.
conan/internal/api/config/config_installer.py Updated _process_folder to use find_file_walk_up for locating the .conanignore file.

Comment thread conan/internal/api/config/config_installer.py Outdated
with chdir(folder_conan_runs):
conan_home = get_conan_user_home()
assert _temp_folder == conan_home
class TestConanUserHome:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same tests here, just moved to a class

@franramirez688 franramirez688 merged commit eeb0630 into conan-io:develop2 May 7, 2025
15 checks passed
@AbrilRBS AbrilRBS deleted the ar/conanignore-walk-tree branch May 7, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants