mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Updated changelog file format
This commit is contained in:
committed by
Nikhil Badyal
parent
1fbeeaef17
commit
993b429eb1
@@ -11,7 +11,7 @@ from src.downloader.download import Downloader
|
||||
from src.exceptions import AppNotFoundError, BuilderError, PatchesJsonLoadError, PatchingFailedError
|
||||
from src.parser import Parser
|
||||
from src.patches import Patches
|
||||
from src.utils import check_java, delete_old_changelog, save_patch_info
|
||||
from src.utils import check_java, delete_old_changelog, save_patch_info, write_changelog_to_file
|
||||
|
||||
|
||||
def get_app(config: RevancedConfig, app_name: str) -> APP:
|
||||
@@ -52,6 +52,7 @@ def main() -> None:
|
||||
logger.exception(e)
|
||||
except BuilderError as e:
|
||||
logger.exception(f"Failed to build {possible_app} because of {e}")
|
||||
write_changelog_to_file()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+30
-25
@@ -34,6 +34,7 @@ request_timeout = 60
|
||||
session = Session()
|
||||
session.headers["User-Agent"] = request_header["User-Agent"]
|
||||
updates_file = "updates.json"
|
||||
changelogs: dict[str, dict[str, str]] = {}
|
||||
|
||||
|
||||
def update_changelog(name: str, response: dict[str, str]) -> None:
|
||||
@@ -48,12 +49,11 @@ def update_changelog(name: str, response: dict[str, str]) -> None:
|
||||
in the dictionary represent the type of change (e.g., "bug fix", "feature", "documentation"), and
|
||||
the values represent the specific changes made for each type.
|
||||
"""
|
||||
parent_repo = get_parent_repo()
|
||||
change_log = format_changelog(name, response, parent_repo)
|
||||
write_to_file(change_log)
|
||||
app_change_log = format_changelog(name, response)
|
||||
changelogs[name] = app_change_log
|
||||
|
||||
|
||||
def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> str:
|
||||
def format_changelog(name: str, response: dict[str, str]) -> dict[str, str]:
|
||||
"""The `format_changelog` returns formatted changelog string.
|
||||
|
||||
Parameters
|
||||
@@ -64,34 +64,39 @@ def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> s
|
||||
response : Dict[str, str]
|
||||
The `response` parameter is a dictionary that contains information about a release. It has the
|
||||
following keys:
|
||||
parent_repo : str
|
||||
The `parent_repo` parameter is a string that represents the URL or name of the parent repository.
|
||||
It is used to generate a footer in the formatted changelog, indicating that the changelogs were
|
||||
generated by a specific tool or script.
|
||||
|
||||
Returns
|
||||
-------
|
||||
a formatted changelog as a string.
|
||||
a formatted changelog as a dict.
|
||||
"""
|
||||
collapse_start = f"\n<details> <summary>👀 {name} </summary>\n\n"
|
||||
release_version = f"**Release Version** - [{response['tag_name']}]({response['html_url']})<br>"
|
||||
change_log = f"**Changelog** -<br> {response['body']}"
|
||||
publish_time = f"**Published at** -<br> {response['published_at']}"
|
||||
footer = f"<br><sub>Change logs generated by [Docker Py Revanced]({parent_repo})</sub>\n"
|
||||
collapse_end = "</details>"
|
||||
return f"{collapse_start}{release_version}{change_log}{publish_time}{footer}{collapse_end}"
|
||||
final_name = f"[{name}]({response['html_url']})"
|
||||
return {
|
||||
"Name": final_name,
|
||||
"Version": response["tag_name"],
|
||||
"Changelog": response["body"],
|
||||
"Published at": response["published_at"],
|
||||
}
|
||||
|
||||
|
||||
def write_to_file(change_log: str) -> None:
|
||||
"""The function `write_to_file` writes a given changelog string to a file.
|
||||
def write_changelog_to_file() -> None:
|
||||
"""The function `write_changelog_to_file` writes a given changelog json to a file."""
|
||||
markdown_table = (
|
||||
"| AppName | Version | Changelog | Published At |\n" + "|---------|---------|-----------|--------------|\n"
|
||||
)
|
||||
for app_data in changelogs.values():
|
||||
name_link = app_data["Name"]
|
||||
version = app_data["Version"]
|
||||
changelog = app_data["Changelog"]
|
||||
published_at = app_data["Published at"]
|
||||
|
||||
Parameters
|
||||
----------
|
||||
change_log : str
|
||||
A string representing the changelog that you want to write to the file.
|
||||
"""
|
||||
with Path(changelog_file).open("a", encoding="utf_8") as file1:
|
||||
file1.write(change_log)
|
||||
# Clean up changelog for markdown
|
||||
changelog = changelog.replace("\r\n", "<br>")
|
||||
changelog = changelog.replace("\n", "<br>")
|
||||
|
||||
# Add row to the Markdown table string
|
||||
markdown_table += f"| {name_link} | {version} | {changelog} | {published_at} |\n"
|
||||
with Path(changelog_file).open("w", encoding="utf_8") as file1:
|
||||
file1.write(markdown_table)
|
||||
|
||||
|
||||
def get_parent_repo() -> str:
|
||||
|
||||
Reference in New Issue
Block a user