mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +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
|
!ct_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
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
|
METHODS determine_path
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!iv_package TYPE tadir-devclass
|
!iv_package TYPE tadir-devclass
|
||||||
|
@ -103,53 +111,67 @@ CLASS zcl_abapgit_tadir IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD add_namespaces.
|
METHOD add_namespace.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
lv_name TYPE progname,
|
lv_name TYPE progname,
|
||||||
lv_namespace TYPE namespace,
|
lv_namespace TYPE namespace.
|
||||||
lv_prev_namespace TYPE namespace,
|
|
||||||
lt_tadir_nspc TYPE zif_abapgit_definitions=>ty_tadir_tt.
|
|
||||||
|
|
||||||
FIELD-SYMBOLS:
|
FIELD-SYMBOLS <ls_tadir> LIKE LINE OF ct_tadir.
|
||||||
<ls_tadir> LIKE LINE OF ct_tadir,
|
|
||||||
<ls_nspc> 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
|
IF sy-subrc = 0 AND lv_namespace IS NOT INITIAL.
|
||||||
lv_name = <ls_tadir>-obj_name.
|
|
||||||
|
|
||||||
CALL FUNCTION 'RS_NAME_SPLIT_NAMESPACE'
|
READ TABLE ct_tadir TRANSPORTING NO FIELDS
|
||||||
EXPORTING
|
WITH KEY pgmid = 'R3TR' object = 'NSPC' obj_name = lv_namespace.
|
||||||
name_with_namespace = lv_name
|
IF sy-subrc <> 0.
|
||||||
IMPORTING
|
APPEND INITIAL LINE TO ct_tadir ASSIGNING <ls_tadir>.
|
||||||
namespace = lv_namespace
|
<ls_tadir>-pgmid = 'R3TR'.
|
||||||
EXCEPTIONS
|
<ls_tadir>-object = 'NSPC'.
|
||||||
delimiter_error = 1
|
<ls_tadir>-obj_name = lv_namespace.
|
||||||
OTHERS = 2.
|
<ls_tadir>-devclass = iv_package.
|
||||||
|
<ls_tadir>-srcsystem = sy-sysid.
|
||||||
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.
|
|
||||||
ENDIF.
|
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.
|
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.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,15 @@ CLASS zcl_abapgit_objects DEFINITION
|
||||||
!ii_log TYPE REF TO zif_abapgit_log
|
!ii_log TYPE REF TO zif_abapgit_log
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
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
|
CLASS-METHODS deserialize_objects
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!is_step TYPE zif_abapgit_objects=>ty_step_data
|
!is_step TYPE zif_abapgit_objects=>ty_step_data
|
||||||
|
@ -674,15 +683,17 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
||||||
|
|
||||||
"error handling & logging added
|
"error handling & logging added
|
||||||
TRY.
|
TRY.
|
||||||
" If package does not exist yet, it will be created with this call
|
IF ls_item-obj_type <> 'NSPC'.
|
||||||
lv_package = lo_folder_logic->path_to_package(
|
" If package does not exist yet, it will be created with this call
|
||||||
iv_top = io_repo->get_package( )
|
lv_package = lo_folder_logic->path_to_package(
|
||||||
io_dot = io_repo->get_dot_abapgit( )
|
iv_top = io_repo->get_package( )
|
||||||
iv_path = <ls_result>-path ).
|
io_dot = io_repo->get_dot_abapgit( )
|
||||||
|
iv_path = <ls_result>-path ).
|
||||||
|
|
||||||
check_main_package(
|
check_main_package(
|
||||||
iv_package = lv_package
|
iv_package = lv_package
|
||||||
iv_obj_type = ls_item-obj_type ).
|
iv_obj_type = ls_item-obj_type ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
IF ls_item-obj_type = 'DEVC'.
|
IF ls_item-obj_type = 'DEVC'.
|
||||||
" Packages have the same filename across different folders. The path needs to be supplied
|
" 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( ).
|
li_progress->off( ).
|
||||||
|
|
||||||
"run deserialize for all steps and it's objects
|
"run deserialize for all steps and its objects
|
||||||
SORT lt_steps BY order.
|
deserialize_steps(
|
||||||
LOOP AT lt_steps ASSIGNING <ls_step>.
|
EXPORTING
|
||||||
deserialize_objects(
|
it_steps = lt_steps
|
||||||
EXPORTING
|
ii_log = ii_log
|
||||||
is_step = <ls_step>
|
iv_transport = is_checks-transport-transport
|
||||||
ii_log = ii_log
|
CHANGING
|
||||||
iv_transport = is_checks-transport-transport
|
ct_files = rt_accessed_files ).
|
||||||
CHANGING
|
|
||||||
ct_files = rt_accessed_files ).
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
update_package_tree( io_repo->get_package( ) ).
|
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( ).
|
zcl_abapgit_default_transport=>get_instance( )->reset( ).
|
||||||
|
|
||||||
lo_timer->end( abap_true ).
|
lo_timer->end( abap_true ).
|
||||||
|
@ -868,6 +873,26 @@ CLASS zcl_abapgit_objects IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
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.
|
METHOD determine_i18n_params.
|
||||||
|
|
||||||
" TODO: unify with ZCL_ABAPGIT_SERIALIZE=>DETERMINE_I18N_PARAMS, same code
|
" 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>-descr = 'Post-process Objects'.
|
||||||
<ls_step>-syntax_check = abap_true.
|
<ls_step>-syntax_check = abap_true.
|
||||||
<ls_step>-order = 4.
|
<ls_step>-order = 4.
|
||||||
|
|
||||||
|
SORT rt_steps BY order. " ensure correct processing order
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.
|
CLASS zcl_abapgit_services_repo IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD activate_objects.
|
METHOD activate_objects.
|
||||||
|
@ -338,10 +338,16 @@ CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.
|
||||||
|
|
||||||
lt_decision = cs_checks-overwrite.
|
lt_decision = cs_checks-overwrite.
|
||||||
|
|
||||||
" Set all new objects to YES
|
" If there's a new namespace, it has to be pulled before all other objects
|
||||||
LOOP AT lt_decision ASSIGNING <ls_decision> WHERE action = zif_abapgit_objects=>c_deserialize_action-add.
|
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.
|
<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
|
" Ask user what to do
|
||||||
popup_overwrite( CHANGING ct_overwrite = lt_decision ).
|
popup_overwrite( CHANGING ct_overwrite = lt_decision ).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user