diff --git a/README.md b/README.md index e2dd853..40b0778 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,12 @@ The action is extracting all the Pull Requests that are declared in the description of the Pull Request with `Depends-On: ` syntax. +If you need to specify a subdir for a particular PR, use the following syntax: + +```txt +Depends-On: ?subdir= +``` + It then injects the needed changes in the code to use the other Pull Requests. ### Go lang diff --git a/python.py b/python.py index 42151d7..483814b 100644 --- a/python.py +++ b/python.py @@ -8,6 +8,7 @@ def lookup_name(fname): "Lookup the name of a module" if os.path.exists(fname): + print(f"Looking up name in {fname}", file=sys.stderr) with open(fname, "r", encoding="UTF-8") as in_stream: for line in in_stream.readlines(): match = re.match(r"^\s*name\s*=\s*['\"](.*?)['\"]\s*,", line) @@ -48,6 +49,10 @@ def process_python_requirements(main_dir, dirs, container_mode): if container_mode: # doc at https://pip.pypa.io/en/stable/cli/pip_install/#git pkg = f"{mod} @ git+{module_dirs[mod]['fork_url']}@{module_dirs[mod]['branch']}" + if "subdir" in module_dirs[mod]: + pkg += ( + f"#egg=subdir&subdirectory={module_dirs[mod]['subdir']}" + ) print( f"Replacing {mod} in requirements.txt with {pkg}", file=sys.stderr, @@ -86,7 +91,13 @@ def process_python_pyproject(main_dir, dirs, container_mode): mod = match.group(1) if container_mode: # doc at https://python-poetry.org/docs/dependency-specification/#git-dependencies - pkg = f"{mod} = {{ git = \"{module_dirs[mod]['fork_url']}\", branch = \"{module_dirs[mod]['branch']}\" }}" + pkg = f"{mod} = {{ git = \"{module_dirs[mod]['fork_url']}\", branch = \"{module_dirs[mod]['branch']}\"" + if "subdir" in module_dirs[mod]: + pkg += ( + f", subdirectory = \"{module_dirs[mod]['subdir']}\" }}" + ) + else: + pkg += " }" print( f"Replacing {mod} in pyproject.toml with {pkg}", file=sys.stderr, diff --git a/stage1.py b/stage1.py index 9838585..426d355 100755 --- a/stage1.py +++ b/stage1.py @@ -147,7 +147,7 @@ def main(check_mode): nb_unmerged_pr = 0 for depends_on_url in depends_on: - merged = extract_depends_on(depends_on_url, check_mode) + merged = extract_depends_on(depends_on_url.strip(), check_mode) if not merged: nb_unmerged_pr += 1