mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
NSPC: Automatic creation of namespaces (#6210)
This commit is contained in:
parent
3c9674a213
commit
5d44df51ba
|
@ -52,6 +52,14 @@ CLASS zcl_abapgit_tadir DEFINITION
|
|||
!ct_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS add_namespace
|
||||
IMPORTING
|
||||
!iv_package TYPE devclass
|
||||
!iv_object TYPE csequence
|
||||
CHANGING
|
||||
!ct_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS determine_path
|
||||
IMPORTING
|
||||
!iv_package TYPE tadir-devclass
|
||||
|
@ -103,53 +111,67 @@ CLASS zcl_abapgit_tadir IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD add_namespaces.
|
||||
METHOD add_namespace.
|
||||
|
||||
DATA:
|
||||
lv_name TYPE progname,
|
||||
lv_namespace TYPE namespace,
|
||||
lv_prev_namespace TYPE namespace,
|
||||
lt_tadir_nspc TYPE zif_abapgit_definitions=>ty_tadir_tt.
|
||||
lv_name TYPE progname,
|
||||
lv_namespace TYPE namespace.
|
||||
|
||||
FIELD-SYMBOLS:
|
||||
<ls_tadir> LIKE LINE OF ct_tadir,
|
||||
<ls_nspc> LIKE LINE OF ct_tadir.
|
||||
FIELD-SYMBOLS <ls_tadir> LIKE LINE OF ct_tadir.
|
||||
|
||||
lv_name = iv_object.
|
||||
|
||||
LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE obj_name(1) = '/'.
|
||||
CALL FUNCTION 'RS_NAME_SPLIT_NAMESPACE'
|
||||
EXPORTING
|
||||
name_with_namespace = lv_name
|
||||
IMPORTING
|
||||
namespace = lv_namespace
|
||||
EXCEPTIONS
|
||||
delimiter_error = 1
|
||||
OTHERS = 2.
|
||||
|
||||
" Namespaces are not in TADIR, but are necessary for creating objects in transportable packages
|
||||
lv_name = <ls_tadir>-obj_name.
|
||||
IF sy-subrc = 0 AND lv_namespace IS NOT INITIAL.
|
||||
|
||||
CALL FUNCTION 'RS_NAME_SPLIT_NAMESPACE'
|
||||
EXPORTING
|
||||
name_with_namespace = lv_name
|
||||
IMPORTING
|
||||
namespace = lv_namespace
|
||||
EXCEPTIONS
|
||||
delimiter_error = 1
|
||||
OTHERS = 2.
|
||||
|
||||
IF sy-subrc = 0 AND lv_namespace IS NOT INITIAL
|
||||
AND lv_namespace <> lv_prev_namespace.
|
||||
|
||||
READ TABLE lt_tadir_nspc TRANSPORTING NO FIELDS
|
||||
WITH KEY pgmid = 'R3TR' object = 'NSPC' obj_name = lv_namespace.
|
||||
IF sy-subrc <> 0.
|
||||
APPEND INITIAL LINE TO ct_tadir ASSIGNING <ls_nspc>.
|
||||
<ls_nspc>-pgmid = 'R3TR'.
|
||||
<ls_nspc>-object = 'NSPC'.
|
||||
<ls_nspc>-obj_name = lv_namespace.
|
||||
<ls_nspc>-devclass = iv_package.
|
||||
<ls_nspc>-srcsystem = sy-sysid.
|
||||
|
||||
INSERT <ls_nspc> INTO TABLE lt_tadir_nspc.
|
||||
ENDIF.
|
||||
lv_prev_namespace = lv_namespace.
|
||||
READ TABLE ct_tadir TRANSPORTING NO FIELDS
|
||||
WITH KEY pgmid = 'R3TR' object = 'NSPC' obj_name = lv_namespace.
|
||||
IF sy-subrc <> 0.
|
||||
APPEND INITIAL LINE TO ct_tadir ASSIGNING <ls_tadir>.
|
||||
<ls_tadir>-pgmid = 'R3TR'.
|
||||
<ls_tadir>-object = 'NSPC'.
|
||||
<ls_tadir>-obj_name = lv_namespace.
|
||||
<ls_tadir>-devclass = iv_package.
|
||||
<ls_tadir>-srcsystem = sy-sysid.
|
||||
ENDIF.
|
||||
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD add_namespaces.
|
||||
|
||||
FIELD-SYMBOLS <ls_tadir> LIKE LINE OF ct_tadir.
|
||||
|
||||
" Namespaces are not in TADIR, but are necessary for creating objects in transportable packages
|
||||
LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE obj_name(1) = '/'.
|
||||
add_namespace(
|
||||
EXPORTING
|
||||
iv_package = iv_package
|
||||
iv_object = <ls_tadir>-obj_name
|
||||
CHANGING
|
||||
ct_tadir = ct_tadir ).
|
||||
ENDLOOP.
|
||||
|
||||
" Root package of repo might not exist yet but needs to be considered, too
|
||||
IF iv_package CP '/*'.
|
||||
add_namespace(
|
||||
EXPORTING
|
||||
iv_package = iv_package
|
||||
iv_object = iv_package
|
||||
CHANGING
|
||||
ct_tadir = ct_tadir ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
|
|
@ -139,6 +139,15 @@ CLASS zcl_abapgit_objects DEFINITION
|
|||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS deserialize_steps
|
||||
IMPORTING
|
||||
!it_steps TYPE zif_abapgit_objects=>ty_step_data_tt
|
||||
!ii_log TYPE REF TO zif_abapgit_log
|
||||
!iv_transport TYPE trkorr
|
||||
CHANGING
|
||||
!ct_files TYPE zif_abapgit_git_definitions=>ty_file_signatures_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS deserialize_objects
|
||||
IMPORTING
|
||||
!is_step TYPE zif_abapgit_objects=>ty_step_data
|
||||
|
@ -674,15 +683,17 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
|||
|
||||
"error handling & logging added
|
||||
TRY.
|
||||
" If package does not exist yet, it will be created with this call
|
||||
lv_package = lo_folder_logic->path_to_package(
|
||||
iv_top = io_repo->get_package( )
|
||||
io_dot = io_repo->get_dot_abapgit( )
|
||||
iv_path = <ls_result>-path ).
|
||||
IF ls_item-obj_type <> 'NSPC'.
|
||||
" If package does not exist yet, it will be created with this call
|
||||
lv_package = lo_folder_logic->path_to_package(
|
||||
iv_top = io_repo->get_package( )
|
||||
io_dot = io_repo->get_dot_abapgit( )
|
||||
iv_path = <ls_result>-path ).
|
||||
|
||||
check_main_package(
|
||||
iv_package = lv_package
|
||||
iv_obj_type = ls_item-obj_type ).
|
||||
check_main_package(
|
||||
iv_package = lv_package
|
||||
iv_obj_type = ls_item-obj_type ).
|
||||
ENDIF.
|
||||
|
||||
IF ls_item-obj_type = 'DEVC'.
|
||||
" Packages have the same filename across different folders. The path needs to be supplied
|
||||
|
@ -763,23 +774,17 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
|||
|
||||
li_progress->off( ).
|
||||
|
||||
"run deserialize for all steps and it's objects
|
||||
SORT lt_steps BY order.
|
||||
LOOP AT lt_steps ASSIGNING <ls_step>.
|
||||
deserialize_objects(
|
||||
EXPORTING
|
||||
is_step = <ls_step>
|
||||
ii_log = ii_log
|
||||
iv_transport = is_checks-transport-transport
|
||||
CHANGING
|
||||
ct_files = rt_accessed_files ).
|
||||
ENDLOOP.
|
||||
"run deserialize for all steps and its objects
|
||||
deserialize_steps(
|
||||
EXPORTING
|
||||
it_steps = lt_steps
|
||||
ii_log = ii_log
|
||||
iv_transport = is_checks-transport-transport
|
||||
CHANGING
|
||||
ct_files = rt_accessed_files ).
|
||||
|
||||
update_package_tree( io_repo->get_package( ) ).
|
||||
|
||||
SORT rt_accessed_files BY path ASCENDING filename ASCENDING.
|
||||
DELETE ADJACENT DUPLICATES FROM rt_accessed_files. " Just in case
|
||||
|
||||
zcl_abapgit_default_transport=>get_instance( )->reset( ).
|
||||
|
||||
lo_timer->end( abap_true ).
|
||||
|
@ -868,6 +873,26 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD deserialize_steps.
|
||||
|
||||
FIELD-SYMBOLS <ls_step> LIKE LINE OF it_steps.
|
||||
|
||||
LOOP AT it_steps ASSIGNING <ls_step>.
|
||||
deserialize_objects(
|
||||
EXPORTING
|
||||
is_step = <ls_step>
|
||||
ii_log = ii_log
|
||||
iv_transport = iv_transport
|
||||
CHANGING
|
||||
ct_files = ct_files ).
|
||||
ENDLOOP.
|
||||
|
||||
SORT ct_files BY path ASCENDING filename ASCENDING.
|
||||
DELETE ADJACENT DUPLICATES FROM ct_files. " Just in case
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD determine_i18n_params.
|
||||
|
||||
" TODO: unify with ZCL_ABAPGIT_SERIALIZE=>DETERMINE_I18N_PARAMS, same code
|
||||
|
@ -942,6 +967,8 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
|||
<ls_step>-descr = 'Post-process Objects'.
|
||||
<ls_step>-syntax_check = abap_true.
|
||||
<ls_step>-order = 4.
|
||||
|
||||
SORT rt_steps BY order. " ensure correct processing order
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.
|
||||
CLASS zcl_abapgit_services_repo IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD activate_objects.
|
||||
|
@ -338,10 +338,16 @@ CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.
|
|||
|
||||
lt_decision = cs_checks-overwrite.
|
||||
|
||||
" Set all new objects to YES
|
||||
LOOP AT lt_decision ASSIGNING <ls_decision> WHERE action = zif_abapgit_objects=>c_deserialize_action-add.
|
||||
" If there's a new namespace, it has to be pulled before all other objects
|
||||
READ TABLE lt_decision ASSIGNING <ls_decision> WITH KEY obj_type = 'NSPC'.
|
||||
IF sy-subrc = 0 AND <ls_decision>-action = zif_abapgit_objects=>c_deserialize_action-add.
|
||||
<ls_decision>-decision = zif_abapgit_definitions=>c_yes.
|
||||
ENDLOOP.
|
||||
ELSE.
|
||||
" Set all new objects to YES
|
||||
LOOP AT lt_decision ASSIGNING <ls_decision> WHERE action = zif_abapgit_objects=>c_deserialize_action-add.
|
||||
<ls_decision>-decision = zif_abapgit_definitions=>c_yes.
|
||||
ENDLOOP.
|
||||
ENDIF.
|
||||
|
||||
" Ask user what to do
|
||||
popup_overwrite( CHANGING ct_overwrite = lt_decision ).
|
||||
|
|
Loading…
Reference in New Issue
Block a user