Skip to content

Commit

Permalink
fix move_folder_contents (#13873)
Browse files Browse the repository at this point in the history
* fix move_folder_contents

* rename arg
  • Loading branch information
memsharded authored May 11, 2023
1 parent 82fcf85 commit ff199b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions conan/tools/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,10 @@ def collect_libs(conanfile, folder=None):
return result


# TODO: Do NOT document this yet. It is unclear the interface, maybe should be split
def move_folder_contents(src_folder, dst_folder):
""" replaces the current folder contents with the contents of one child folder. This
is used in the SCM monorepo flow, when it is necessary to use one subproject subfolder
to replace the whole cloned git repo
def move_folder_contents(conanfile, src_folder, dst_folder):
""" replaces the dst_folder contents with the contents of the src_folder, which can be a
child folder of dst_folder. This is used in the SCM monorepo flow, when it is necessary
to use one subproject subfolder to replace the whole cloned git repo
/base-folder /base-folder
/pkg (src folder) /other/<otherfiles>
/other/<otherfiles> /pkg/<pkgfiles>
Expand Down
4 changes: 2 additions & 2 deletions conans/test/functional/tools/scm/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def source(self):
sources = self.conan_data["sources"]
git.clone(url=sources["url"], target=".")
git.checkout(commit=sources["commit"])
move_folder_contents(os.path.join(self.source_folder, sources["folder"]),
move_folder_contents(self, os.path.join(self.source_folder, sources["folder"]),
self.source_folder)
def build(self):
Expand Down Expand Up @@ -598,7 +598,7 @@ def source(self):
# Final we want is pkg/<files> and common/<files>
# NOTE: This abs_path is IMPORTANT to avoid the trailing "."
src_folder = os.path.abspath(self.source_folder)
move_folder_contents(src_folder, os.path.dirname(src_folder))
move_folder_contents(self, src_folder, os.path.dirname(src_folder))
def build(self):
cmake = CMake(self)
Expand Down

0 comments on commit ff199b0

Please sign in to comment.