mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
Skipping serialization for ignored objects (#5648)
* Skipping serialization for ignored objects Serialization now evaluates the ignore list and skips matching objects. Note: The match is using the ABAP `cp` operator. Example: ``` *ztest.prog.* Ignore individual program *.ectd.* Ignore all objects of a given type */subpack/* Ignore all objects in a sub-package ```
This commit is contained in:
parent
89090b5c00
commit
d427c6cfe7
|
@ -25,10 +25,10 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@abaplint/cli": "^2.91.4",
|
||||
"@abaplint/runtime": "^2.0.45",
|
||||
"@abaplint/transpiler-cli": "^2.0.45",
|
||||
"@abaplint/database-sqlite": "^2.0.30",
|
||||
"@abaplint/cli": "^2.91.5",
|
||||
"@abaplint/runtime": "^2.0.47",
|
||||
"@abaplint/transpiler-cli": "^2.0.47",
|
||||
"@abaplint/database-sqlite": "^2.0.46",
|
||||
"abapmerge": "^0.14.7",
|
||||
"c8": "^7.11.3",
|
||||
"eslint": "^8.18.0"
|
||||
|
|
|
@ -108,6 +108,13 @@ CLASS zcl_abapgit_serialize DEFINITION
|
|||
METHODS filter_unsupported_objects
|
||||
CHANGING
|
||||
!ct_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt .
|
||||
METHODS filter_ignored_objects
|
||||
IMPORTING
|
||||
!iv_package TYPE devclass
|
||||
CHANGING
|
||||
!ct_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -359,6 +366,85 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD filter_ignored_objects.
|
||||
|
||||
DATA:
|
||||
ls_ignored_count TYPE ty_unsupported_count,
|
||||
lt_ignored_count TYPE ty_unsupported_count_tt,
|
||||
lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic,
|
||||
ls_item TYPE zif_abapgit_definitions=>ty_item,
|
||||
lv_path TYPE string,
|
||||
lv_filename TYPE string.
|
||||
|
||||
FIELD-SYMBOLS:
|
||||
<ls_tadir> LIKE LINE OF ct_tadir,
|
||||
<ls_ignored_count> TYPE ty_unsupported_count.
|
||||
|
||||
" Ignore logic requires .abapGit.xml
|
||||
IF mo_dot_abapgit IS INITIAL OR iv_package IS INITIAL OR mi_log IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ).
|
||||
|
||||
LOOP AT ct_tadir ASSIGNING <ls_tadir>.
|
||||
CLEAR: ls_ignored_count.
|
||||
|
||||
ls_item-obj_type = <ls_tadir>-object.
|
||||
ls_item-obj_name = <ls_tadir>-obj_name.
|
||||
|
||||
IF <ls_tadir>-devclass IS NOT INITIAL.
|
||||
lv_path = lo_folder_logic->package_to_path(
|
||||
iv_top = iv_package
|
||||
io_dot = mo_dot_abapgit
|
||||
iv_package = <ls_tadir>-devclass ).
|
||||
ELSE.
|
||||
lv_path = mo_dot_abapgit->get_starting_folder( ).
|
||||
ENDIF.
|
||||
|
||||
lv_filename = zcl_abapgit_filename_logic=>object_to_file(
|
||||
is_item = ls_item
|
||||
iv_ext = '*' ).
|
||||
|
||||
IF mo_dot_abapgit->is_ignored(
|
||||
iv_path = lv_path
|
||||
iv_filename = lv_filename ) = abap_false.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_ignored_count ASSIGNING <ls_ignored_count> WITH TABLE KEY obj_type = <ls_tadir>-object.
|
||||
IF sy-subrc <> 0.
|
||||
ls_ignored_count-obj_type = <ls_tadir>-object.
|
||||
ls_ignored_count-count = 1.
|
||||
ls_ignored_count-obj_name = <ls_tadir>-obj_name.
|
||||
INSERT ls_ignored_count INTO TABLE lt_ignored_count ASSIGNING <ls_ignored_count>.
|
||||
ELSE.
|
||||
CLEAR: <ls_ignored_count>-obj_name.
|
||||
<ls_ignored_count>-count = <ls_ignored_count>-count + 1.
|
||||
ENDIF.
|
||||
" init object so we can remove these entries afterwards
|
||||
CLEAR <ls_tadir>-object.
|
||||
ENDLOOP.
|
||||
IF lt_ignored_count IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
" remove ignored objects
|
||||
DELETE ct_tadir WHERE object IS INITIAL.
|
||||
|
||||
LOOP AT lt_ignored_count ASSIGNING <ls_ignored_count>.
|
||||
IF <ls_ignored_count>-count = 1.
|
||||
mi_log->add_warning( iv_msg = |Object { <ls_ignored_count>-obj_type } {
|
||||
<ls_ignored_count>-obj_name } ignored| ).
|
||||
ELSE.
|
||||
mi_log->add_warning( iv_msg = |Object type { <ls_ignored_count>-obj_type } with {
|
||||
<ls_ignored_count>-count } objects ignored| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD filter_unsupported_objects.
|
||||
|
||||
DATA: ls_unsupported_count TYPE ty_unsupported_count,
|
||||
|
@ -542,6 +628,13 @@ CLASS zcl_abapgit_serialize IMPLEMENTATION.
|
|||
|
||||
lt_tadir = it_tadir.
|
||||
filter_unsupported_objects( CHANGING ct_tadir = lt_tadir ).
|
||||
|
||||
filter_ignored_objects(
|
||||
EXPORTING
|
||||
iv_package = iv_package
|
||||
CHANGING
|
||||
ct_tadir = lt_tadir ).
|
||||
|
||||
li_progress = zcl_abapgit_progress=>get_instance( lines( lt_tadir ) ).
|
||||
|
||||
LOOP AT lt_tadir ASSIGNING <ls_tadir>.
|
||||
|
|
|
@ -55,12 +55,14 @@ CLASS ltcl_serialize DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS F
|
|||
|
||||
PRIVATE SECTION.
|
||||
DATA:
|
||||
mo_dot TYPE REF TO zcl_abapgit_dot_abapgit,
|
||||
mo_cut TYPE REF TO zcl_abapgit_serialize.
|
||||
|
||||
METHODS:
|
||||
setup,
|
||||
test FOR TESTING RAISING zcx_abapgit_exception,
|
||||
unsupported FOR TESTING RAISING zcx_abapgit_exception.
|
||||
unsupported FOR TESTING RAISING zcx_abapgit_exception,
|
||||
ignored FOR TESTING RAISING zcx_abapgit_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -68,8 +70,13 @@ ENDCLASS.
|
|||
CLASS ltcl_serialize IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
|
||||
mo_dot = zcl_abapgit_dot_abapgit=>build_default( ).
|
||||
|
||||
TRY.
|
||||
CREATE OBJECT mo_cut.
|
||||
CREATE OBJECT mo_cut
|
||||
EXPORTING
|
||||
io_dot_abapgit = mo_dot.
|
||||
CATCH zcx_abapgit_exception.
|
||||
cl_abap_unit_assert=>fail( 'Error creating serializer' ).
|
||||
ENDTRY.
|
||||
|
@ -149,6 +156,62 @@ CLASS ltcl_serialize IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignored.
|
||||
|
||||
DATA: lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt,
|
||||
ls_msg TYPE zif_abapgit_log=>ty_log_out,
|
||||
lt_msg TYPE zif_abapgit_log=>ty_log_outs,
|
||||
li_log1 TYPE REF TO zif_abapgit_log,
|
||||
li_log2 TYPE REF TO zif_abapgit_log.
|
||||
|
||||
FIELD-SYMBOLS: <ls_tadir> LIKE LINE OF lt_tadir.
|
||||
|
||||
mo_dot->add_ignore(
|
||||
iv_path = '/src/'
|
||||
iv_filename = 'zcl_test_ignore.clas.*' ).
|
||||
|
||||
APPEND INITIAL LINE TO lt_tadir ASSIGNING <ls_tadir>.
|
||||
<ls_tadir>-object = 'CLAS'.
|
||||
<ls_tadir>-obj_name = 'ZCL_TEST'.
|
||||
<ls_tadir>-devclass = '$ZTEST'.
|
||||
|
||||
APPEND INITIAL LINE TO lt_tadir ASSIGNING <ls_tadir>.
|
||||
<ls_tadir>-object = 'CLAS'.
|
||||
<ls_tadir>-obj_name = 'ZCL_TEST_IGNORE'.
|
||||
<ls_tadir>-devclass = '$ZTEST'.
|
||||
|
||||
CREATE OBJECT li_log1 TYPE zcl_abapgit_log.
|
||||
mo_cut->serialize(
|
||||
iv_package = '$ZTEST'
|
||||
it_tadir = lt_tadir
|
||||
ii_log = li_log1
|
||||
iv_force_sequential = abap_true ).
|
||||
|
||||
CREATE OBJECT li_log2 TYPE zcl_abapgit_log.
|
||||
mo_cut->serialize(
|
||||
iv_package = '$ZTEST'
|
||||
it_tadir = lt_tadir
|
||||
ii_log = li_log2
|
||||
iv_force_sequential = abap_false ).
|
||||
|
||||
lt_msg = li_log1->get_messages( ).
|
||||
READ TABLE lt_msg INTO ls_msg INDEX 1.
|
||||
cl_abap_unit_assert=>assert_subrc( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_char_cp(
|
||||
act = ls_msg-text
|
||||
exp = '*Object CLAS ZCL_TEST_IGNORE ignored*' ).
|
||||
|
||||
lt_msg = li_log2->get_messages( ).
|
||||
READ TABLE lt_msg INTO ls_msg INDEX 1.
|
||||
cl_abap_unit_assert=>assert_subrc( ).
|
||||
|
||||
cl_abap_unit_assert=>assert_char_cp(
|
||||
act = ls_msg-text
|
||||
exp = '*Object CLAS ZCL_TEST_IGNORE ignored*' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS ltcl_i18n DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL.
|
||||
|
|
Loading…
Reference in New Issue
Block a user