From 72f359a1d8ba6550cdc92657479755e7dd6610ec Mon Sep 17 00:00:00 2001 From: Sumit Jain Date: Fri, 13 Sep 2024 13:22:26 +0530 Subject: [PATCH 1/2] Refactor: use app_logo if app_logo_url is not present --- commit/api/meta_data.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commit/api/meta_data.py b/commit/api/meta_data.py index 4b82a6e..b657076 100644 --- a/commit/api/meta_data.py +++ b/commit/api/meta_data.py @@ -3,6 +3,13 @@ @frappe.whitelist() def get_installed_apps(): + ''' + Get all installed apps + 1. Get the installed applications from the Installed Applications doctype + 2. Get the app hooks for each app + 3. Get the app description, publisher, logo, version and git branch + 4. Return the updated apps + ''' install_app_doc = frappe.get_cached_doc('Installed Applications') install_apps = install_app_doc.get('installed_applications') updated_apps = [] @@ -18,7 +25,7 @@ def get_installed_apps(): if app_publisher is not None: app_publisher = app_publisher[0] - app_logo_url = app_hooks.get('app_logo_url') + app_logo_url = app_hooks.get('app_logo_url') or app_hooks.get('app_logo') if app_logo_url is not None: app_logo_url = app_logo_url[0] From f6dd5667c353307f94128d997e7695badb3a8250 Mon Sep 17 00:00:00 2001 From: Sumit Jain Date: Fri, 13 Sep 2024 18:09:34 +0530 Subject: [PATCH 2/2] Refactor: Improve error handling in get_name_of_app function if repo name is not valid fix: TypeError: string indices must be integers, not 'str'` when creating a new Commit Project #62 --- commit/api/code_analysis.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/commit/api/code_analysis.py b/commit/api/code_analysis.py index 1407719..ef81590 100644 --- a/commit/api/code_analysis.py +++ b/commit/api/code_analysis.py @@ -9,20 +9,23 @@ def get_name_of_app(organization, repo): ''' Get name of app from repo ''' - type = None + file_type = None app_name = None root_files = get_all_files_in_repo(access_token, organization, repo) + if type(root_files) == dict and root_files.get("message", "") == "Not Found": + return frappe.throw(f'Repository {repo} not found in organization {organization}') + for file in root_files: if file["name"] == "pyproject.toml": - type = "pyproject.toml" + file_type = "pyproject.toml" break elif file["name"] == "setup.py": - type = "setup.py" + file_type = "setup.py" break - if type == "pyproject.toml": + if file_type == "pyproject.toml": app_name = get_app_name_from_pyproject_toml(organization, repo) - elif type == "setup.py": + elif file_type == "setup.py": app_name = get_app_name_from_setup_py(organization, repo) return app_name