mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:43:01 +00:00
[WINESYNC] Elegantly handle empty 'files' and 'directories' lists.
Expand on Timo's commit 4b5a55516
.
We may encounter cases where either the 'directories' or 'files' lists
in the .cfg YAML files are empty, and we don't want the script to throw
an exception in that case.
Furthermore, explicitly check for such empty lists when calling PyGit2
index.add_all(...) function, because if it's called on a None or empty
list, _all_ untracked files in the selected git repository get added,
which is not what we want there.
This commit is contained in:
parent
67ca439d06
commit
7f8d2d14b7
1 changed files with 9 additions and 7 deletions
|
@ -99,7 +99,7 @@ class wine_sync:
|
||||||
# Helper function for resolving wine tree path to reactos one
|
# Helper function for resolving wine tree path to reactos one
|
||||||
# Note: it doesn't care about the fact that the file actually exists or not
|
# Note: it doesn't care about the fact that the file actually exists or not
|
||||||
def wine_to_reactos_path(self, wine_path):
|
def wine_to_reactos_path(self, wine_path):
|
||||||
if wine_path in self.module_cfg['files']:
|
if self.module_cfg['files'] and (wine_path in self.module_cfg['files']):
|
||||||
# we have a direct mapping
|
# we have a direct mapping
|
||||||
return self.module_cfg['files'][wine_path]
|
return self.module_cfg['files'][wine_path]
|
||||||
|
|
||||||
|
@ -107,11 +107,8 @@ class wine_sync:
|
||||||
# root files should have a direct mapping
|
# root files should have a direct mapping
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.module_cfg['directories'] is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
wine_dir, wine_file = os.path.split(wine_path)
|
wine_dir, wine_file = os.path.split(wine_path)
|
||||||
if wine_dir in self.module_cfg['directories']:
|
if self.module_cfg['directories'] and (wine_dir in self.module_cfg['directories']):
|
||||||
# we have a mapping for the directory
|
# we have a mapping for the directory
|
||||||
return posixpath.join(self.module_cfg['directories'][wine_dir], wine_file)
|
return posixpath.join(self.module_cfg['directories'][wine_dir], wine_file)
|
||||||
|
|
||||||
|
@ -295,7 +292,12 @@ class wine_sync:
|
||||||
if not has_patches:
|
if not has_patches:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Note: these path lists may be empty or None, in which case
|
||||||
|
# we should not call index.add_all(), otherwise we would add
|
||||||
|
# any untracked file present in the repository.
|
||||||
|
if self.module_cfg['files']:
|
||||||
self.reactos_index.add_all([f for f in self.module_cfg['files'].values()])
|
self.reactos_index.add_all([f for f in self.module_cfg['files'].values()])
|
||||||
|
if self.module_cfg['directories']:
|
||||||
self.reactos_index.add_all([f'{d}/*.*' for d in self.module_cfg['directories'].values()])
|
self.reactos_index.add_all([f'{d}/*.*' for d in self.module_cfg['directories'].values()])
|
||||||
self.reactos_index.write()
|
self.reactos_index.write()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue