Fix dump when deleting repo with DB utility (#5740)

* Fix dump when deleting repo with DB utility

Ref #5612

- Avoid dump when manually deleting entries with DB Utility
- Avoid inconsistency when deleting repo entry but not repo checksums
- Improve warning popup and error message

* Fix warning

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2022-09-07 08:41:41 -04:00 committed by GitHub
parent df62cb6ff4
commit dd58dac4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 6 deletions

View File

@ -234,6 +234,8 @@ CLASS lcl_repo_mock IMPLEMENTATION.
METHOD zif_abapgit_repo~checksums.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~init.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~delete.
ENDMETHOD.
METHOD zif_abapgit_repo~get_local_settings.

View File

@ -326,7 +326,7 @@ CLASS zcl_abapgit_repo_srv IMPLEMENTATION.
ENDLOOP.
ENDDO.
zcx_abapgit_exception=>raise( 'repo not found, get' ).
zcx_abapgit_exception=>raise( |Repository not found in database. Key: REPO, { iv_key }| ).
ENDMETHOD.
@ -402,6 +402,11 @@ CLASS zcl_abapgit_repo_srv IMPLEMENTATION.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~init.
CLEAR mv_init.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~is_repo_installed.
DATA: lt_repo TYPE zif_abapgit_repo_srv=>ty_repo_list,

View File

@ -5,6 +5,7 @@ INTERFACE zif_abapgit_repo_srv
TYPES:
ty_repo_list TYPE STANDARD TABLE OF REF TO zif_abapgit_repo WITH DEFAULT KEY .
METHODS init.
METHODS delete
IMPORTING
!ii_repo TYPE REF TO zif_abapgit_repo

View File

@ -149,10 +149,10 @@ CLASS zcl_abapgit_gui_page_db IMPLEMENTATION.
lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm(
iv_titlebar = 'Warning'
iv_text_question = 'Delete?'
iv_text_button_1 = 'Ok'
iv_text_question = |Are you sure you want to delete entry { is_key-type } { is_key-value }?|
iv_text_button_1 = 'Yes'
iv_icon_button_1 = 'ICON_DELETE'
iv_text_button_2 = 'Cancel'
iv_text_button_2 = 'No'
iv_icon_button_2 = 'ICON_CANCEL'
iv_default_button = '2'
iv_display_cancel_button = abap_false ).
@ -165,6 +165,17 @@ CLASS zcl_abapgit_gui_page_db IMPLEMENTATION.
iv_type = is_key-type
iv_value = is_key-value ).
" If deleting repo, also delete corresponding checksums
" Other way around is ok, since checksums are automatically recreated
IF is_key-type = zcl_abapgit_persistence_db=>c_type_repo.
zcl_abapgit_persistence_db=>get_instance( )->delete(
iv_type = zcl_abapgit_persistence_db=>c_type_repo_csum
iv_value = is_key-value ).
" Initialize repo list
zcl_abapgit_repo_srv=>get_instance( )->init( ).
ENDIF.
COMMIT WORK.
ENDMETHOD.

View File

@ -193,7 +193,7 @@ ENDCLASS.
CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW IMPLEMENTATION.
CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
METHOD apply_order_by.
@ -825,6 +825,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW IMPLEMENTATION.
gui_services( )->register_event_handler( me ).
CREATE OBJECT mo_repo_aggregated_state.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
TRY.
" Reinit, for the case of type change
mo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( mo_repo->get_key( ) ).
@ -834,7 +836,6 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_VIEW IMPLEMENTATION.
lo_news = zcl_abapgit_news=>create( mo_repo ).
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
ri_html->add( |<div class="repo" id="repo{ mv_key }">| ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top(
io_repo = mo_repo