From 67093085f689bd649188c95070ef9a9e00bcda10 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Fri, 7 Oct 2022 15:00:31 -0400 Subject: [PATCH] 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 --- src/objects/oo/zcl_abapgit_oo_class.clas.abap | 39 ++++++++++++++++--- .../oo/zcl_abapgit_oo_interface.clas.abap | 34 ++++++++++++++-- .../oo/zif_abapgit_oo_object_fnc.intf.abap | 2 +- src/objects/zcl_abapgit_object_clas.clas.abap | 20 ++-------- src/objects/zcl_abapgit_object_intf.clas.abap | 14 ++----- 5 files changed, 73 insertions(+), 36 deletions(-) diff --git a/src/objects/oo/zcl_abapgit_oo_class.clas.abap b/src/objects/oo/zcl_abapgit_oo_class.clas.abap index 60ba6fe1b..741f36928 100644 --- a/src/objects/oo/zcl_abapgit_oo_class.clas.abap +++ b/src/objects/oo/zcl_abapgit_oo_class.clas.abap @@ -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: 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: TYPE seoclsname. ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO . 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 = . + ls_properties = zif_abapgit_oo_object_fnc~get_class_properties( ls_class_key ). + lt_attributes = zif_abapgit_oo_object_fnc~read_attributes( ). + + IF ls_properties = cg_properties AND lt_attributes = it_attributes. + RETURN. + ENDIF. + ENDIF. + lt_vseoattrib = convert_attrib_to_vseoattrib( iv_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. diff --git a/src/objects/oo/zcl_abapgit_oo_interface.clas.abap b/src/objects/oo/zcl_abapgit_oo_interface.clas.abap index 2396c743c..f22c332ac 100644 --- a/src/objects/oo/zcl_abapgit_oo_interface.clas.abap +++ b/src/objects/oo/zcl_abapgit_oo_interface.clas.abap @@ -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: TYPE seoclsname. ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO . 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 = . + 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 = 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. diff --git a/src/objects/oo/zif_abapgit_oo_object_fnc.intf.abap b/src/objects/oo/zif_abapgit_oo_object_fnc.intf.abap index f9b32c6a0..1f78e627e 100644 --- a/src/objects/oo/zif_abapgit_oo_object_fnc.intf.abap +++ b/src/objects/oo/zif_abapgit_oo_object_fnc.intf.abap @@ -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 diff --git a/src/objects/zcl_abapgit_object_clas.clas.abap b/src/objects/zcl_abapgit_object_clas.clas.abap index 89ce69035..1749e8007 100644 --- a/src/objects/zcl_abapgit_object_clas.clas.abap +++ b/src/objects/zcl_abapgit_object_clas.clas.abap @@ -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. diff --git a/src/objects/zcl_abapgit_object_intf.clas.abap b/src/objects/zcl_abapgit_object_intf.clas.abap index 7d5a55985..0eb0f295a 100644 --- a/src/objects/zcl_abapgit_object_intf.clas.abap +++ b/src/objects/zcl_abapgit_object_intf.clas.abap @@ -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 ).