Skip to content

Commit

Permalink
check for changes before pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
olinux committed Jun 29, 2023
1 parent 7370119 commit af530ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
37 changes: 2 additions & 35 deletions pipeline/toctree.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import json
import os.path
from typing import List, Optional
from typing import List

from rstcloth import RstCloth



def create_toc_tree_page(version:str, relative_path:List[str]):
target_file = os.path.join("target", f"{version}/docs/{'/'.join(relative_path)}.rst")
os.makedirs(os.path.dirname(target_file), exist_ok=True)
Expand All @@ -27,34 +24,4 @@ def create_toc_tree_page(version:str, relative_path:List[str]):
new_relative_path = []
new_relative_path.extend(relative_path)
new_relative_path.append(sub_dir)
create_toc_tree_page(version, new_relative_path)
#
# def create_specifications(version:str):
# create_toc_tree_page(version, ["specifications"])
#
#
# target_file = os.path.join("target", f"{version}/specifications.rst")
# os.makedirs(os.path.dirname(target_file), exist_ok=True)
# with open(target_file, "w") as output_file:
# doc = RstCloth(output_file, line_width=160)
# doc.heading("Specifications", char="#", overline=True)
# doc.newline()
# #TODO add some description -> but where does it come from?
# doc.content(f".. toctree::")
# doc.newline()
# for module in sorted(os.listdir(os.path.join("target", version, "specifications")), key=str.casefold):
# doc.content(f"specifications/{module}", indent=3)
#
#
# def create_module_page(version:str, module:Optional[List[str]):
# target_file = os.path.join("target", f"{version}/specifications/{module}.rst")
# os.makedirs(os.path.dirname(target_file), exist_ok=True)
# with open(target_file, "w") as output_file:
# doc = RstCloth(output_file, line_width=160)
# doc.heading(module, char="#", overline=True)
# doc.newline()
# # TODO add some description -> but where does it come from?
# doc.content(f".. toctree::")
# doc.newline()
# for schema in sorted(os.listdir(os.path.join("target", version, "specifications", module)), key=str.casefold):
# doc.content(f"{module}", indent=3)
create_toc_tree_page(version, new_relative_path)
9 changes: 7 additions & 2 deletions pipeline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ def upload(self, version):
self._clear_directory()
shutil.copytree(f"target/{version}", self.upload_dir, dirs_exist_ok=True)
self._repo.git.add('--all')
self._repo.index.commit(f'Updating documentation for version {version}')
self._repo.git.push("origin", version)
diff_list = self._repo.head.commit.diff()
if diff_list:
print(f"{len(diff_list)} changes found - pushing to origin")
self._repo.index.commit(f'Updating documentation for version {version}')
self._repo.git.push("origin", version)
else:
print("No changes - nothing to commit")

def _clear_directory(self):
for item in os.listdir(self.upload_dir):
Expand Down

0 comments on commit af530ee

Please sign in to comment.