-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstacks.py
More file actions
47 lines (34 loc) · 1 KB
/
Copy pathstacks.py
File metadata and controls
47 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import logging
from pathlib import Path
from config import STACKS_ROOT
def find_stacks(stacks_root: Path):
stacks = []
for path in stacks_root.iterdir():
if not path.is_dir():
continue
if any(
(path / name).exists()
for name in (
"docker-compose.yml",
"docker-compose.yaml",
"compose.yml",
"compose.yaml",
)
):
stacks.append(path)
return stacks
def get_changed_stacks(changed_files, stacks_root: Path):
stacks = set()
stacks_root_rel = stacks_root.relative_to(STACKS_ROOT)
for file in changed_files:
path = Path(file)
try:
relative = path.relative_to(stacks_root_rel)
except ValueError:
continue
if not relative.parts:
continue
stack_dir = stacks_root / relative.parts[0]
if stack_dir.is_dir():
stacks.add(stack_dir)
return sorted(stacks)