mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
Add user exit for serialize postprocessing (#5194)
There are scenarios where you want to serialize objects differently than abapGit. This exit is called at the end of the serialize process and gives an opportunity to change the content of the serialzed files. One such scenario would be to automatically pretty-print code. This can be achieved by looping over all `.abap` files and processing them accordingly in this exit. Closes #5050 Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
97d8723b6f
commit
c7e4af3be2
|
@ -15,6 +15,7 @@ CLASS zcl_abapgit_serialize DEFINITION
|
|||
!p_task TYPE clike ##NEEDED.
|
||||
METHODS serialize
|
||||
IMPORTING
|
||||
!iv_package TYPE devclass OPTIONAL
|
||||
!it_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||
!ii_log TYPE REF TO zif_abapgit_log OPTIONAL
|
||||
!iv_force_sequential TYPE abap_bool DEFAULT abap_false
|
||||
|
@ -156,7 +157,7 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
IMPORTING
|
||||
es_item = <ls_return>-item ).
|
||||
|
||||
<ls_return>-item-obj_type = 'TABU'.
|
||||
<ls_return>-item-obj_type = zif_abapgit_data_config=>c_data_type-tabu.
|
||||
ENDLOOP.
|
||||
|
||||
lt_files = zcl_abapgit_data_factory=>get_serializer( )->serialize( ii_data_config ).
|
||||
|
@ -212,6 +213,7 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
lv_force = boolc( lines( lt_tadir ) < 10 ).
|
||||
|
||||
lt_found = serialize(
|
||||
iv_package = iv_package
|
||||
it_tadir = lt_tadir
|
||||
ii_log = ii_log
|
||||
iv_force_sequential = lv_force ).
|
||||
|
@ -523,6 +525,7 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
|
||||
DATA: lv_max TYPE i,
|
||||
li_progress TYPE REF TO zif_abapgit_progress,
|
||||
li_exit TYPE REF TO zif_abapgit_exit,
|
||||
lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt.
|
||||
|
||||
FIELD-SYMBOLS: <ls_tadir> LIKE LINE OF it_tadir.
|
||||
|
@ -558,5 +561,15 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
rt_files = mt_files.
|
||||
FREE mt_files.
|
||||
|
||||
* Call postprocessing
|
||||
li_exit = zcl_abapgit_exit=>get_instance( ).
|
||||
|
||||
li_exit->serialize_postprocess(
|
||||
EXPORTING
|
||||
iv_package = iv_package
|
||||
ii_log = ii_log
|
||||
CHANGING
|
||||
ct_files = rt_files ).
|
||||
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
|
|
@ -689,7 +689,9 @@ CLASS zcl_abapgit_repo IMPLEMENTATION.
|
|||
INSERT ls_tadir INTO TABLE lt_tadir.
|
||||
|
||||
CREATE OBJECT lo_serialize.
|
||||
lt_new_local_files = lo_serialize->serialize( lt_tadir ).
|
||||
lt_new_local_files = lo_serialize->serialize(
|
||||
iv_package = ms_data-package
|
||||
it_tadir = lt_tadir ).
|
||||
|
||||
INSERT LINES OF lt_new_local_files INTO TABLE mt_local.
|
||||
|
||||
|
|
|
@ -281,6 +281,23 @@ CLASS zcl_abapgit_exit IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zif_abapgit_exit~serialize_postprocess.
|
||||
|
||||
IF gi_exit IS NOT INITIAL.
|
||||
TRY.
|
||||
gi_exit->serialize_postprocess(
|
||||
EXPORTING
|
||||
iv_package = iv_package
|
||||
ii_log = ii_log
|
||||
CHANGING
|
||||
ct_files = ct_files ).
|
||||
CATCH cx_sy_ref_is_initial cx_sy_dyn_call_illegal_method ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zif_abapgit_exit~wall_message_list.
|
||||
|
||||
IF gi_exit IS NOT INITIAL.
|
||||
|
|
|
@ -100,6 +100,12 @@ INTERFACE zif_abapgit_exit
|
|||
VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS serialize_postprocess
|
||||
IMPORTING
|
||||
!iv_package TYPE devclass
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
CHANGING
|
||||
!ct_files TYPE zif_abapgit_definitions=>ty_files_item_tt.
|
||||
METHODS adjust_display_filename
|
||||
IMPORTING
|
||||
!iv_filename TYPE string
|
||||
|
|
Loading…
Reference in New Issue
Block a user