CLAS,ENHO: Fix inactive enhancements (#5810)

* CLAS,ENHO: Fix inactive enhancements

When pulling a change to an existing class, existing enhancement where inactivated and the enhancement code deleted. 

This was caused by unnecessarily calling `CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE'` in `zcl_abapgit_oo_class->create`, twice.

The change avoids the second call if the class properties and attributes have *not* been changed. Interfaces are handled the same way. 

Tested with CI tests for classes and interfaces:


Closes #5809

* Clear

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2022-10-07 15:00:31 -04:00 committed by GitHub
parent 3ecf82777c
commit 67093085f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 36 deletions

View File

@ -433,14 +433,29 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
METHOD zif_abapgit_oo_object_fnc~create.
DATA: lt_vseoattrib TYPE seoo_attributes_r.
FIELD-SYMBOLS: <lv_clsname> TYPE seoclsname.
DATA:
lt_vseoattrib TYPE seoo_attributes_r,
ls_class_key TYPE seoclskey,
ls_properties TYPE vseoclass,
lt_attributes TYPE zif_abapgit_definitions=>ty_obj_attribute_tt.
* same as in super class, but with "version = seoc_version_active"
FIELD-SYMBOLS: <lv_clsname> TYPE seoclsname.
ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO <lv_clsname>.
ASSERT sy-subrc = 0.
" Get existing class properties and attributes and check if the class
" needs to be created/updated (or is the same)
IF iv_check = abap_true.
ls_class_key-clsname = <lv_clsname>.
ls_properties = zif_abapgit_oo_object_fnc~get_class_properties( ls_class_key ).
lt_attributes = zif_abapgit_oo_object_fnc~read_attributes( <lv_clsname> ).
IF ls_properties = cg_properties AND lt_attributes = it_attributes.
RETURN.
ENDIF.
ENDIF.
lt_vseoattrib = convert_attrib_to_vseoattrib(
iv_clsname = <lv_clsname>
it_attributes = it_attributes ).
@ -449,7 +464,7 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE'
EXPORTING
devclass = iv_package
overwrite = iv_overwrite
overwrite = abap_true
version = seoc_version_active
suppress_dialog = abap_true " Parameter missing in 702
CHANGING
@ -467,7 +482,7 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE'
EXPORTING
devclass = iv_package
overwrite = iv_overwrite
overwrite = abap_true
version = seoc_version_active
CHANGING
class = cg_properties
@ -685,6 +700,20 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION.
ELSEIF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
CLEAR:
rs_class_properties-uuid,
rs_class_properties-author,
rs_class_properties-createdon,
rs_class_properties-changedby,
rs_class_properties-changedon,
rs_class_properties-r3release,
rs_class_properties-chgdanyby,
rs_class_properties-chgdanyon,
rs_class_properties-clsfinal,
rs_class_properties-clsabstrct,
rs_class_properties-exposure,
rs_class_properties-version.
ENDMETHOD.

View File

@ -157,12 +157,28 @@ CLASS zcl_abapgit_oo_interface IMPLEMENTATION.
METHOD zif_abapgit_oo_object_fnc~create.
DATA: lt_vseoattrib TYPE seoo_attributes_r.
DATA:
lt_vseoattrib TYPE seoo_attributes_r,
ls_interface_key TYPE seoclskey,
ls_properties TYPE vseointerf.
FIELD-SYMBOLS: <lv_clsname> TYPE seoclsname.
ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO <lv_clsname>.
ASSERT sy-subrc = 0.
" Get existing interface properties and check if the interface
" needs to be created/updated (or is the same)
IF iv_check = abap_true.
ls_interface_key-clsname = <lv_clsname>.
ls_properties = zif_abapgit_oo_object_fnc~get_interface_properties( ls_interface_key ).
IF ls_properties = cg_properties.
RETURN.
ENDIF.
ENDIF.
lt_vseoattrib = convert_attrib_to_vseoattrib(
iv_clsname = <lv_clsname>
it_attributes = it_attributes ).
@ -171,7 +187,7 @@ CLASS zcl_abapgit_oo_interface IMPLEMENTATION.
CALL FUNCTION 'SEO_INTERFACE_CREATE_COMPLETE'
EXPORTING
devclass = iv_package
overwrite = iv_overwrite
overwrite = abap_true
version = seoc_version_active
suppress_dialog = abap_true " Parameter missing in 702
CHANGING
@ -189,7 +205,7 @@ CLASS zcl_abapgit_oo_interface IMPLEMENTATION.
CALL FUNCTION 'SEO_INTERFACE_CREATE_COMPLETE'
EXPORTING
devclass = iv_package
overwrite = iv_overwrite
overwrite = abap_true
version = seoc_version_active
CHANGING
interface = cg_properties
@ -206,6 +222,7 @@ CLASS zcl_abapgit_oo_interface IMPLEMENTATION.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
@ -298,5 +315,16 @@ CLASS zcl_abapgit_oo_interface IMPLEMENTATION.
ELSEIF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
CLEAR:
rs_interface_properties-uuid,
rs_interface_properties-author,
rs_interface_properties-createdon,
rs_interface_properties-changedby,
rs_interface_properties-changedon,
rs_interface_properties-chgdanyby,
rs_interface_properties-chgdanyon,
rs_interface_properties-r3release,
rs_interface_properties-version.
ENDMETHOD.
ENDCLASS.

View File

@ -21,8 +21,8 @@ INTERFACE zif_abapgit_oo_object_fnc PUBLIC.
METHODS:
create
IMPORTING
iv_check TYPE abap_bool
iv_package TYPE devclass
iv_overwrite TYPE abap_bool DEFAULT abap_true
it_attributes TYPE zif_abapgit_definitions=>ty_obj_attribute_tt OPTIONAL
CHANGING
cg_properties TYPE any

View File

@ -181,6 +181,7 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
mi_object_oriented_object_fct->create(
EXPORTING
iv_check = abap_true
iv_package = iv_package
it_attributes = lt_attributes
CHANGING
@ -279,16 +280,16 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
METHOD deserialize_pre_ddic.
DATA: ls_vseoclass TYPE vseoclass,
lt_attributes TYPE zif_abapgit_definitions=>ty_obj_attribute_tt.
DATA: ls_vseoclass TYPE vseoclass.
ii_xml->read( EXPORTING iv_name = 'VSEOCLASS'
CHANGING cg_data = ls_vseoclass ).
mi_object_oriented_object_fct->create(
EXPORTING
iv_check = abap_false
iv_package = iv_package
it_attributes = lt_attributes
CHANGING
cg_properties = ls_vseoclass ).
@ -634,19 +635,6 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
zcl_abapgit_language=>restore_login_language( ).
CLEAR: ls_vseoclass-uuid,
ls_vseoclass-author,
ls_vseoclass-createdon,
ls_vseoclass-changedby,
ls_vseoclass-changedon,
ls_vseoclass-r3release,
ls_vseoclass-chgdanyby,
ls_vseoclass-chgdanyon,
ls_vseoclass-clsfinal,
ls_vseoclass-clsabstrct,
ls_vseoclass-exposure,
ls_vseoclass-version.
IF mv_skip_testclass = abap_true.
CLEAR ls_vseoclass-with_unit_tests.
ENDIF.

View File

@ -185,7 +185,7 @@ CLASS zcl_abapgit_object_intf IMPLEMENTATION.
METHOD deserialize_pre_ddic.
DATA: ls_intf TYPE ty_intf.
DATA ls_intf TYPE ty_intf.
IF zcl_abapgit_persist_factory=>get_settings( )->read( )->get_experimental_features( ) = abap_true.
ls_intf = read_json( ).
@ -196,6 +196,7 @@ CLASS zcl_abapgit_object_intf IMPLEMENTATION.
mi_object_oriented_object_fct->create(
EXPORTING
iv_check = abap_false
iv_package = iv_package
CHANGING
cg_properties = ls_intf-vseointerf ).
@ -381,16 +382,6 @@ CLASS zcl_abapgit_object_intf IMPLEMENTATION.
ls_intf-vseointerf = mi_object_oriented_object_fct->get_interface_properties( ls_clskey ).
CLEAR: ls_intf-vseointerf-uuid,
ls_intf-vseointerf-author,
ls_intf-vseointerf-createdon,
ls_intf-vseointerf-changedby,
ls_intf-vseointerf-changedon,
ls_intf-vseointerf-chgdanyby,
ls_intf-vseointerf-chgdanyon,
ls_intf-vseointerf-r3release,
ls_intf-vseointerf-version.
" Select all active translations of documentation
" Skip main language - it was already serialized
SELECT DISTINCT langu
@ -527,6 +518,7 @@ CLASS zcl_abapgit_object_intf IMPLEMENTATION.
ELSE.
mi_object_oriented_object_fct->create(
EXPORTING
iv_check = abap_true
iv_package = iv_package
CHANGING
cg_properties = ls_intf-vseointerf ).