Skip to content

Commit

Permalink
Handled cases when categories are added or deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
risvh committed Mar 28, 2024
1 parent 5454d29 commit 65647e8
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions readableAssets.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,26 @@ def read_category_as_object_list(content):
if inAction:

if 'categories/' in changed_file:
category_before_output = run_command(f"git show {COMMIT_A}:{changed_file}")
category_after_output = run_command(f"git show {COMMIT_B}:{changed_file}")

if category_before_output != "" and category_after_output != "":
category_before, category_after = [], []

if changed_file not in changes_added:
category_before_output = run_command(f"git show {COMMIT_A}:{changed_file}")
category_before = read_category_as_object_list(category_before_output)
if changed_file not in changes_deleted:
category_after_output = run_command(f"git show {COMMIT_B}:{changed_file}")
category_after = read_category_as_object_list(category_after_output)

added = list(set(category_after) - set(category_before))
removed = list(set(category_before) - set(category_after))
category_details = ""
if len(added) > 0:
category_details += "\n".join( [ f"+ {e} {get_object_name_by_id(e)}" for e in added] )
if len(removed) > 0:
category_details += "\n".join( [ f"- {e} {get_object_name_by_id(e)}" for e in removed] )
line = f"""
added = list(set(category_after) - set(category_before))
removed = list(set(category_before) - set(category_after))

category_details = ""
if len(added) > 0:
category_details += "\n".join( [ f"+ {e} {get_object_name_by_id(e)}" for e in added] )
if len(removed) > 0:
category_details += "\n".join( [ f"- {e} {get_object_name_by_id(e)}" for e in removed] )

line = f"""
{sign} [{object_id}](https://github.com/{REPO}/pull/{PR_NUM}/files#diff-{file_hash}) {object_name}
<details>
<summary>Details</summary>
Expand Down

0 comments on commit 65647e8

Please sign in to comment.