From 5ab104636bcde6c097b56db7ef293b6e593eb2d6 Mon Sep 17 00:00:00 2001 From: vladimirhasko Date: Sun, 29 Jan 2023 17:30:21 +0000 Subject: [PATCH 1/5] Replacing shutil copytree by dirsync --- tools-requirements.txt | 1 + tools/sync_doc_repo.py | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools-requirements.txt b/tools-requirements.txt index b82f11a5..382a4a03 100644 --- a/tools-requirements.txt +++ b/tools-requirements.txt @@ -2,3 +2,4 @@ GitPython ruamel.yaml requests jinja2 +dirsync diff --git a/tools/sync_doc_repo.py b/tools/sync_doc_repo.py index abdfc79d..cf924f11 100644 --- a/tools/sync_doc_repo.py +++ b/tools/sync_doc_repo.py @@ -21,6 +21,7 @@ import pathlib import shutil import subprocess import warnings +from dirsync import sync from git import Repo from git import SymbolicReference @@ -111,12 +112,9 @@ def process_repositories(args, service): new_branch.set_tracking_branch(remote_ref) new_branch.checkout() - shutil.copytree( - pathlib.Path(copy_from, doc["rst_location"]), - pathlib.Path(copy_to, doc["rst_location"]), - ignore=lambda a, b: ["conf.py"], - dirs_exist_ok=True, - ) + source_path = pathlib.Path(copy_from, doc["rst_location"]) + target_path = pathlib.Path(copy_to, doc["rst_location"]) + sync(source_path, target_path, purge=True, create=True, exclude=['conf.py']) repo_to.index.add([doc["rst_location"]]) if len(repo_to.index.diff("HEAD")) == 0: # Nothing to commit -- 2.34.1 From c370ffe06ac9d5c581fcf3e61dccd67cb2187216 Mon Sep 17 00:00:00 2001 From: vladimirhasko Date: Sun, 29 Jan 2023 18:08:33 +0000 Subject: [PATCH 2/5] removing obsolete shutil --- tools/sync_doc_repo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/sync_doc_repo.py b/tools/sync_doc_repo.py index cf924f11..5e1e72c6 100644 --- a/tools/sync_doc_repo.py +++ b/tools/sync_doc_repo.py @@ -18,7 +18,6 @@ import argparse import logging import os import pathlib -import shutil import subprocess import warnings from dirsync import sync -- 2.34.1 From 906a426a48441d93786043603da4e94ea38b2f32 Mon Sep 17 00:00:00 2001 From: vladimirhasko Date: Sun, 29 Jan 2023 18:15:11 +0000 Subject: [PATCH 3/5] fixing too long line --- tools/sync_doc_repo.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/sync_doc_repo.py b/tools/sync_doc_repo.py index 5e1e72c6..d9531b4e 100644 --- a/tools/sync_doc_repo.py +++ b/tools/sync_doc_repo.py @@ -113,7 +113,13 @@ def process_repositories(args, service): source_path = pathlib.Path(copy_from, doc["rst_location"]) target_path = pathlib.Path(copy_to, doc["rst_location"]) - sync(source_path, target_path, purge=True, create=True, exclude=['conf.py']) + sync( + source_path, + target_path, + purge=True, + create=True, + exclude=['conf.py'] + ) repo_to.index.add([doc["rst_location"]]) if len(repo_to.index.diff("HEAD")) == 0: # Nothing to commit -- 2.34.1 From d5d68b0d01180217285b9b2a55176d1749595ca8 Mon Sep 17 00:00:00 2001 From: vladimirhasko Date: Sun, 29 Jan 2023 20:05:46 +0000 Subject: [PATCH 4/5] fixing the sync command --- tools/sync_doc_repo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/sync_doc_repo.py b/tools/sync_doc_repo.py index d9531b4e..1299cb3b 100644 --- a/tools/sync_doc_repo.py +++ b/tools/sync_doc_repo.py @@ -116,9 +116,10 @@ def process_repositories(args, service): sync( source_path, target_path, + 'sync', purge=True, create=True, - exclude=['conf.py'] + ignore=['conf.py'] ) repo_to.index.add([doc["rst_location"]]) if len(repo_to.index.diff("HEAD")) == 0: -- 2.34.1 From 031e08d1c7897fa1f373445ac2eaf41c7b57cc06 Mon Sep 17 00:00:00 2001 From: vladimirhasko Date: Sun, 29 Jan 2023 20:54:48 +0000 Subject: [PATCH 5/5] fixing the sync options --- tools/sync_doc_repo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/sync_doc_repo.py b/tools/sync_doc_repo.py index 1299cb3b..46b36357 100644 --- a/tools/sync_doc_repo.py +++ b/tools/sync_doc_repo.py @@ -119,9 +119,13 @@ def process_repositories(args, service): 'sync', purge=True, create=True, + content=True, ignore=['conf.py'] ) repo_to.index.add([doc["rst_location"]]) + + for obj in repo_to.index.diff(None).iter_change_type('D'): + repo_to.index.remove([obj.b_path]) if len(repo_to.index.diff("HEAD")) == 0: # Nothing to commit logging.debug("No changes.") -- 2.34.1