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.exceptions import AppNotFoundError, BuilderError, PatchesJsonLoadError, PatchingFailedError
|
||||||
from src.parser import Parser
|
from src.parser import Parser
|
||||||
from src.patches import Patches
|
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:
|
def get_app(config: RevancedConfig, app_name: str) -> APP:
|
||||||
@@ -52,6 +52,7 @@ def main() -> None:
|
|||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
except BuilderError as e:
|
except BuilderError as e:
|
||||||
logger.exception(f"Failed to build {possible_app} because of {e}")
|
logger.exception(f"Failed to build {possible_app} because of {e}")
|
||||||
|
write_changelog_to_file()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
+30
-25
@@ -34,6 +34,7 @@ request_timeout = 60
|
|||||||
session = Session()
|
session = Session()
|
||||||
session.headers["User-Agent"] = request_header["User-Agent"]
|
session.headers["User-Agent"] = request_header["User-Agent"]
|
||||||
updates_file = "updates.json"
|
updates_file = "updates.json"
|
||||||
|
changelogs: dict[str, dict[str, str]] = {}
|
||||||
|
|
||||||
|
|
||||||
def update_changelog(name: str, response: dict[str, str]) -> None:
|
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
|
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.
|
the values represent the specific changes made for each type.
|
||||||
"""
|
"""
|
||||||
parent_repo = get_parent_repo()
|
app_change_log = format_changelog(name, response)
|
||||||
change_log = format_changelog(name, response, parent_repo)
|
changelogs[name] = app_change_log
|
||||||
write_to_file(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.
|
"""The `format_changelog` returns formatted changelog string.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -64,34 +64,39 @@ def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> s
|
|||||||
response : Dict[str, str]
|
response : Dict[str, str]
|
||||||
The `response` parameter is a dictionary that contains information about a release. It has the
|
The `response` parameter is a dictionary that contains information about a release. It has the
|
||||||
following keys:
|
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
|
Returns
|
||||||
-------
|
-------
|
||||||
a formatted changelog as a string.
|
a formatted changelog as a dict.
|
||||||
"""
|
"""
|
||||||
collapse_start = f"\n<details> <summary>👀 {name} </summary>\n\n"
|
final_name = f"[{name}]({response['html_url']})"
|
||||||
release_version = f"**Release Version** - [{response['tag_name']}]({response['html_url']})<br>"
|
return {
|
||||||
change_log = f"**Changelog** -<br> {response['body']}"
|
"Name": final_name,
|
||||||
publish_time = f"**Published at** -<br> {response['published_at']}"
|
"Version": response["tag_name"],
|
||||||
footer = f"<br><sub>Change logs generated by [Docker Py Revanced]({parent_repo})</sub>\n"
|
"Changelog": response["body"],
|
||||||
collapse_end = "</details>"
|
"Published at": response["published_at"],
|
||||||
return f"{collapse_start}{release_version}{change_log}{publish_time}{footer}{collapse_end}"
|
}
|
||||||
|
|
||||||
|
|
||||||
def write_to_file(change_log: str) -> None:
|
def write_changelog_to_file() -> None:
|
||||||
"""The function `write_to_file` writes a given changelog string to a file.
|
"""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
|
# Clean up changelog for markdown
|
||||||
----------
|
changelog = changelog.replace("\r\n", "<br>")
|
||||||
change_log : str
|
changelog = changelog.replace("\n", "<br>")
|
||||||
A string representing the changelog that you want to write to the file.
|
|
||||||
"""
|
# Add row to the Markdown table string
|
||||||
with Path(changelog_file).open("a", encoding="utf_8") as file1:
|
markdown_table += f"| {name_link} | {version} | {changelog} | {published_at} |\n"
|
||||||
file1.write(change_log)
|
with Path(changelog_file).open("w", encoding="utf_8") as file1:
|
||||||
|
file1.write(markdown_table)
|
||||||
|
|
||||||
|
|
||||||
def get_parent_repo() -> str:
|
def get_parent_repo() -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user