Skip to content

Commit b60267f

Browse files
alxndr42missytake
authored andcommitted
Skip www_folder if merge conflict marker found
1 parent a0aa291 commit b60267f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

cmdeploy/src/cmdeploy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
681681
check_config(config)
682682
mail_domain = config.mail_domain
683683

684-
from .www import build_webpages, get_paths
684+
from .www import build_webpages, find_merge_conflict, get_paths
685685

686686
server.group(name="Create vmail group", group="vmail", system=True)
687687
server.user(name="Create vmail user", user="vmail", group="vmail", system=True)
@@ -823,6 +823,8 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
823823
# if www_folder was set to a non-existing folder, skip upload
824824
if not www_path.is_dir():
825825
logger.warning("Building web pages is disabled in chatmail.ini, skipping")
826+
elif (path := find_merge_conflict(src_dir)) is not None:
827+
logger.warning(f"Merge conflict found in {path}, skipping")
826828
else:
827829
# if www_folder is a hugo page, build it
828830
if build_dir:

cmdeploy/src/cmdeploy/www.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import traceback
55
import webbrowser
66
from pathlib import Path
7+
import re
78

89
import markdown
910
from chatmaild.config import read_config
@@ -12,6 +13,9 @@
1213
from .genqr import gen_qr_png_data
1314

1415

16+
_MERGE_CONFLICT_RE = re.compile(r"^<<<<<<<.+^=======.+^>>>>>>>", re.DOTALL | re.MULTILINE)
17+
18+
1519
def snapshot_dir_stats(somedir):
1620
d = {}
1721
for path in somedir.iterdir():
@@ -116,6 +120,17 @@ def _build_webpages(src_dir, build_dir, config):
116120
return build_dir
117121

118122

123+
def find_merge_conflict(src_dir) -> Path:
124+
assert src_dir.exists(), src_dir
125+
result = None
126+
for path in src_dir.iterdir():
127+
if path.suffix in [".css", ".html", ".md"]:
128+
if _MERGE_CONFLICT_RE.search(path.read_text()):
129+
result = path
130+
break
131+
return result
132+
133+
119134
def main():
120135
path = importlib.resources.files(__package__)
121136
reporoot = path.joinpath("../../../").resolve()

0 commit comments

Comments
 (0)