mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
remove old status code
This commit is contained in:
parent
31727c352e
commit
ebaa76a6c2
|
@ -20,19 +20,7 @@ CLASS lcl_file_status DEFINITION FINAL
|
|||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CLASS-METHODS compare_files
|
||||
IMPORTING it_repo TYPE ty_files_tt
|
||||
is_file TYPE ty_file
|
||||
RETURNING VALUE(rv_match) TYPE sap_bool.
|
||||
|
||||
CLASS-METHODS calculate_status_old
|
||||
IMPORTING it_local TYPE ty_files_item_tt
|
||||
it_remote TYPE ty_files_tt
|
||||
it_tadir TYPE ty_tadir_tt
|
||||
iv_starting_folder TYPE string
|
||||
RETURNING VALUE(rt_results) TYPE ty_results_tt.
|
||||
|
||||
CLASS-METHODS calculate_status_new
|
||||
CLASS-METHODS calculate_status
|
||||
IMPORTING it_local TYPE ty_files_item_tt
|
||||
it_remote TYPE ty_files_tt
|
||||
it_cur_state TYPE ty_file_signatures_tt
|
||||
|
@ -64,18 +52,6 @@ ENDCLASS. "lcl_file_status DEFINITION
|
|||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_file_status IMPLEMENTATION.
|
||||
|
||||
METHOD compare_files.
|
||||
|
||||
READ TABLE it_repo WITH KEY
|
||||
path = is_file-path
|
||||
filename = is_file-filename
|
||||
sha1 = is_file-sha1
|
||||
TRANSPORTING NO FIELDS.
|
||||
|
||||
rv_match = boolc( sy-subrc = 0 ).
|
||||
|
||||
ENDMETHOD. "compare_files
|
||||
|
||||
METHOD status.
|
||||
|
||||
DATA: lv_index LIKE sy-tabix,
|
||||
|
@ -85,13 +61,7 @@ CLASS lcl_file_status IMPLEMENTATION.
|
|||
|
||||
lo_dot_abapgit = io_repo->get_dot_abapgit( ).
|
||||
|
||||
* rt_results = calculate_status_old(
|
||||
* it_local = io_repo->get_files_local( io_log )
|
||||
* it_remote = io_repo->get_files_remote( )
|
||||
* it_tadir = lcl_tadir=>read( io_repo->get_package( ) )
|
||||
* iv_starting_folder = lo_dot_abapgit->get_starting_folder( ) ).
|
||||
|
||||
rt_results = calculate_status_new(
|
||||
rt_results = calculate_status(
|
||||
it_local = io_repo->get_files_local( io_log )
|
||||
it_remote = io_repo->get_files_remote( )
|
||||
it_cur_state = io_repo->get_local_checksums_per_file( ) ).
|
||||
|
@ -124,7 +94,7 @@ CLASS lcl_file_status IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "status
|
||||
|
||||
METHOD calculate_status_new.
|
||||
METHOD calculate_status.
|
||||
|
||||
DATA: lt_remote LIKE it_remote,
|
||||
lt_items TYPE ty_items_tt,
|
||||
|
@ -192,7 +162,7 @@ CLASS lcl_file_status IMPLEMENTATION.
|
|||
obj_name ASCENDING
|
||||
filename ASCENDING.
|
||||
|
||||
ENDMETHOD. "calculate_status_new.
|
||||
ENDMETHOD. "calculate_status.
|
||||
|
||||
METHOD identify_object.
|
||||
|
||||
|
@ -312,147 +282,9 @@ CLASS lcl_file_status IMPLEMENTATION.
|
|||
ENDIF.
|
||||
|
||||
ELSE. " Completely unknown file, probably non-abapgit
|
||||
" No action, just follow defaults
|
||||
ASSERT 1 = 1.
|
||||
ASSERT 1 = 1. " No action, just follow defaults
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "build_new_remote
|
||||
|
||||
METHOD calculate_status_old.
|
||||
|
||||
DATA: lv_pre TYPE tadir-obj_name,
|
||||
lt_files TYPE ty_files_tt,
|
||||
ls_result LIKE LINE OF rt_results,
|
||||
lv_type TYPE string,
|
||||
ls_item TYPE ty_item,
|
||||
ls_tadir TYPE tadir,
|
||||
lv_ext TYPE string.
|
||||
|
||||
FIELD-SYMBOLS: <ls_remote> LIKE LINE OF it_remote,
|
||||
<ls_tadir> LIKE LINE OF it_tadir,
|
||||
<ls_result> LIKE LINE OF rt_results,
|
||||
<ls_local> LIKE LINE OF it_local,
|
||||
<ls_file> LIKE LINE OF lt_files.
|
||||
|
||||
|
||||
LOOP AT it_remote ASSIGNING <ls_remote>.
|
||||
|
||||
" Guess object type and name
|
||||
SPLIT <ls_remote>-filename AT '.' INTO lv_pre lv_type lv_ext.
|
||||
TRANSLATE lv_pre TO UPPER CASE.
|
||||
TRANSLATE lv_type TO UPPER CASE.
|
||||
|
||||
IF lv_ext <> 'xml' OR strlen( lv_type ) <> 4.
|
||||
CONTINUE. " current loop
|
||||
ENDIF.
|
||||
|
||||
" handle namespaces
|
||||
REPLACE ALL OCCURRENCES OF '#' IN lv_pre WITH '/'.
|
||||
|
||||
CLEAR ls_result.
|
||||
ls_result-obj_type = lv_type.
|
||||
ls_result-obj_name = lv_pre.
|
||||
|
||||
CLEAR ls_item.
|
||||
ls_item-obj_type = lv_type.
|
||||
ls_item-obj_name = lv_pre.
|
||||
|
||||
" Add corresponding local files
|
||||
CLEAR lt_files.
|
||||
LOOP AT it_local ASSIGNING <ls_local>
|
||||
WHERE item-obj_type = ls_item-obj_type AND item-obj_name = ls_item-obj_name.
|
||||
APPEND <ls_local>-file TO lt_files.
|
||||
ENDLOOP.
|
||||
|
||||
" item does not exist locally
|
||||
IF lt_files[] IS INITIAL.
|
||||
ls_result-filename = <ls_remote>-filename.
|
||||
ls_result-rstate = gc_state-added.
|
||||
APPEND ls_result TO rt_results.
|
||||
CONTINUE. " current loop
|
||||
ENDIF.
|
||||
|
||||
LOOP AT lt_files ASSIGNING <ls_file>.
|
||||
ls_result-filename = <ls_file>-filename.
|
||||
ls_result-match = compare_files( it_repo = it_remote
|
||||
is_file = <ls_file> ).
|
||||
APPEND ls_result TO rt_results.
|
||||
ENDLOOP.
|
||||
ENDLOOP.
|
||||
|
||||
* find files only existing remotely, including non abapGit related
|
||||
LOOP AT it_remote ASSIGNING <ls_remote>.
|
||||
READ TABLE rt_results WITH KEY filename = <ls_remote>-filename
|
||||
TRANSPORTING NO FIELDS.
|
||||
IF sy-subrc <> 0.
|
||||
CLEAR ls_result.
|
||||
ls_result-match = abap_false.
|
||||
ls_result-rstate = gc_state-added.
|
||||
ls_result-filename = <ls_remote>-filename.
|
||||
APPEND ls_result TO rt_results.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
* add path information for files
|
||||
LOOP AT it_remote ASSIGNING <ls_remote>.
|
||||
READ TABLE rt_results ASSIGNING <ls_result> WITH KEY filename = <ls_remote>-filename.
|
||||
IF sy-subrc = 0.
|
||||
<ls_result>-path = <ls_remote>-path.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
* find objects only existing locally
|
||||
LOOP AT it_tadir ASSIGNING <ls_tadir>.
|
||||
READ TABLE rt_results
|
||||
WITH KEY obj_type = <ls_tadir>-object
|
||||
obj_name = <ls_tadir>-obj_name
|
||||
TRANSPORTING NO FIELDS.
|
||||
IF sy-subrc <> 0.
|
||||
ls_item-obj_type = <ls_tadir>-object.
|
||||
ls_item-obj_name = <ls_tadir>-obj_name.
|
||||
IF lcl_objects=>is_supported( ls_item ) = abap_false.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
CLEAR ls_result.
|
||||
ls_result-match = abap_false.
|
||||
ls_result-obj_type = <ls_tadir>-object.
|
||||
ls_result-obj_name = <ls_tadir>-obj_name.
|
||||
ls_result-lstate = gc_state-added.
|
||||
APPEND ls_result TO rt_results.
|
||||
ENDIF.
|
||||
|
||||
LOOP AT rt_results ASSIGNING <ls_result>
|
||||
WHERE obj_type = <ls_tadir>-object
|
||||
AND obj_name = <ls_tadir>-obj_name
|
||||
AND path IS INITIAL.
|
||||
* new file added locally to existing object
|
||||
<ls_result>-path = iv_starting_folder && <ls_tadir>-path.
|
||||
<ls_result>-lstate = gc_state-added.
|
||||
ENDLOOP.
|
||||
ENDLOOP.
|
||||
|
||||
* add package information
|
||||
LOOP AT rt_results ASSIGNING <ls_result> WHERE NOT obj_type IS INITIAL.
|
||||
CLEAR ls_tadir.
|
||||
READ TABLE it_tadir ASSIGNING <ls_tadir>
|
||||
WITH KEY object = <ls_result>-obj_type obj_name = <ls_result>-obj_name.
|
||||
IF sy-subrc > 0. " Not found -> Another package ?
|
||||
ls_tadir = lcl_tadir=>read_single( iv_object = <ls_result>-obj_type
|
||||
iv_obj_name = <ls_result>-obj_name ).
|
||||
<ls_result>-package = ls_tadir-devclass.
|
||||
ELSE.
|
||||
<ls_result>-package = <ls_tadir>-devclass.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
SORT rt_results BY
|
||||
obj_type ASCENDING
|
||||
obj_name ASCENDING
|
||||
filename ASCENDING.
|
||||
DELETE ADJACENT DUPLICATES FROM rt_results
|
||||
COMPARING obj_type obj_name filename.
|
||||
|
||||
ENDMETHOD. "calculate_status_old
|
||||
|
||||
ENDCLASS. "lcl_file_status IMPLEMENTATION
|
|
@ -1783,13 +1783,6 @@ CLASS ltcl_file_status IMPLEMENTATION.
|
|||
<state>-sha1 = &2.
|
||||
END-OF-DEFINITION.
|
||||
|
||||
DEFINE _append_tadir.
|
||||
APPEND INITIAL LINE TO lt_tadir ASSIGNING <tadir>.
|
||||
<tadir>-object = &1.
|
||||
<tadir>-obj_name = &2.
|
||||
<tadir>-devclass = '$Z$'.
|
||||
END-OF-DEFINITION.
|
||||
|
||||
DEFINE _append_result.
|
||||
APPEND INITIAL LINE TO lt_results_exp ASSIGNING <result>.
|
||||
<result>-obj_type = &1.
|
||||
|
@ -1859,16 +1852,6 @@ CLASS ltcl_file_status IMPLEMENTATION.
|
|||
_append_remote 'xfeld.doma.xml' 'XFELD'. " Object from different package
|
||||
_append_remote 'num01.doma.xml' 'NUM01_CHANGED'. " Changed object from different package
|
||||
|
||||
"TADIR TYPE NAME
|
||||
_append_tadir 'DOMA' 'ZDOMA1'.
|
||||
_append_tadir 'DOMA' 'ZDOMA2'.
|
||||
_append_tadir 'DOMA' 'ZDOMA3'.
|
||||
_append_tadir 'CLAS' 'ZCLASS1'.
|
||||
_append_tadir 'DOMA' 'ZDOMA4'.
|
||||
_append_tadir 'DOMA' 'ZDOMA6'.
|
||||
_append_tadir 'DOMA' 'ZDOMA7'.
|
||||
_append_tadir 'DOMA' 'ZDOMA8'.
|
||||
|
||||
"EXP RESULT TYPE NAME MATCH LST RST PKG FILE
|
||||
_append_result '' '' ' ' ' ' 'A' '' 'textfile.txt'.
|
||||
_append_result 'CLAS' 'ZCLASS1' ' ' ' ' 'A' '$Z$' 'zclass1.clas.abap'.
|
||||
|
@ -1887,13 +1870,7 @@ CLASS ltcl_file_status IMPLEMENTATION.
|
|||
_append_result 'DOMA' 'ZDOMA7' 'X' ' ' ' ' '$Z$' 'zdoma7.doma.xml'.
|
||||
_append_result 'DOMA' 'ZDOMA8' ' ' 'M' 'M' '$Z$' 'zdoma8.doma.xml'.
|
||||
|
||||
* lt_results = lcl_file_status=>calculate_status_old(
|
||||
* it_local = lt_local
|
||||
* it_remote = lt_remote
|
||||
* it_tadir = lt_tadir
|
||||
* iv_starting_folder = '/' ).
|
||||
|
||||
lt_results = lcl_file_status=>calculate_status_new(
|
||||
lt_results = lcl_file_status=>calculate_status(
|
||||
it_local = lt_local
|
||||
it_remote = lt_remote
|
||||
it_cur_state = lt_state ).
|
||||
|
|
Loading…
Reference in New Issue
Block a user