Merge branch 'main' into mbtools/prog_flow_logic

This commit is contained in:
Lars Hvam 2024-10-29 05:40:28 +01:00 committed by GitHub
commit 26e852d230
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 78 additions and 28 deletions

View File

@ -23,7 +23,7 @@
]
},
"devDependencies": {
"@abaplint/cli": "^2.113.21",
"@abaplint/cli": "^2.113.31",
"@abaplint/database-sqlite": "^2.10.20",
"@abaplint/runtime": "^2.10.20",
"express": "^4.21.1",
@ -31,6 +31,6 @@
"globals": "^15.11.0",
"abapmerge": "^0.16.6",
"c8": "^10.1.2",
"eslint": "^9.12.0"
"eslint": "^9.13.0"
}
}

View File

@ -178,14 +178,18 @@ CLASS zcl_abapgit_git_pack IMPLEMENTATION.
lv_data = iv_data.
* header
IF NOT xstrlen( lv_data ) > 4 OR lv_data(4) <> c_pack_start.
zcx_abapgit_exception=>raise( |Unexpected pack header| ).
IF xstrlen( lv_data ) < 4.
zcx_abapgit_exception=>raise( |Unexpected pack header, short reply| ).
ENDIF.
IF lv_data(4) <> c_pack_start.
zcx_abapgit_exception=>raise( |Unexpected pack header, { lv_data(4) }| ).
ENDIF.
lv_data = lv_data+4.
* version
IF lv_data(4) <> c_version.
zcx_abapgit_exception=>raise( |Version not supported| ).
zcx_abapgit_exception=>raise( |Version not supported, { lv_data(4) }| ).
ENDIF.
lv_data = lv_data+4.

View File

@ -75,7 +75,13 @@ CLASS zcl_abapgit_diff DEFINITION
METHODS create_regex_set
RETURNING
VALUE(rt_regex_set) TYPE ty_regexset_tt.
METHODS compute_and_render
METHODS compute_diff
IMPORTING
!it_new TYPE rswsourcet
!it_old TYPE rswsourcet
RETURNING
VALUE(rt_diff) TYPE zif_abapgit_definitions=>ty_diffs_tt.
METHODS compute_diff_extra
IMPORTING
!it_new TYPE rswsourcet
!it_old TYPE rswsourcet
@ -187,7 +193,7 @@ CLASS zcl_abapgit_diff IMPLEMENTATION.
ENDMETHOD.
METHOD compute_and_render.
METHOD compute_diff.
DATA:
lv_i TYPE i,
@ -195,8 +201,6 @@ CLASS zcl_abapgit_diff IMPLEMENTATION.
lt_delta TYPE STANDARD TABLE OF rsedcresul WITH DEFAULT KEY.
FIELD-SYMBOLS:
<ls_old> LIKE LINE OF it_old,
<ls_new> LIKE LINE OF it_new,
<ls_delta> LIKE LINE OF lt_delta.
" Note: Ignore case is for keywords, variables, types etc, but not for literals
@ -245,22 +249,9 @@ CLASS zcl_abapgit_diff IMPLEMENTATION.
APPEND ls_diff TO rt_diff.
ENDLOOP.
ELSEIF sy-subrc = 2.
" Copy input... but it might not be identical
LOOP AT it_old ASSIGNING <ls_old>.
CLEAR ls_diff.
ls_diff-old_num = sy-tabix.
ls_diff-old = <ls_old>.
READ TABLE it_new ASSIGNING <ls_new> INDEX sy-tabix.
ASSERT sy-subrc = 0.
ls_diff-new_num = sy-tabix.
ls_diff-new = <ls_new>.
" SAP function ignores lines that contain only whitespace so we compare directly
IF ( mv_compare_mode = 1 OR mv_compare_mode = 3 ) AND <ls_old> <> <ls_new> AND
( strlen( condense( <ls_old> ) ) = 0 OR strlen( condense( <ls_new> ) ) = 0 ).
ls_diff-result = zif_abapgit_definitions=>c_diff-update.
ENDIF.
APPEND ls_diff TO rt_diff.
ENDLOOP.
" The function doesn't find all diffs...
rt_diff = compute_diff_extra( it_new = it_new
it_old = it_old ).
ELSE.
ASSERT 0 = 1. " incorrect function call
ENDIF.
@ -268,6 +259,53 @@ CLASS zcl_abapgit_diff IMPLEMENTATION.
ENDMETHOD.
METHOD compute_diff_extra.
DATA:
lv_last_new TYPE c LENGTH 1,
lv_last_old TYPE c LENGTH 1,
ls_diff LIKE LINE OF rt_diff.
FIELD-SYMBOLS:
<ls_old> LIKE LINE OF it_old,
<ls_new> LIKE LINE OF it_new.
LOOP AT it_old ASSIGNING <ls_old>.
CLEAR ls_diff.
ls_diff-old_num = sy-tabix.
ls_diff-old = <ls_old>.
READ TABLE it_new ASSIGNING <ls_new> INDEX sy-tabix.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ls_diff-new_num = sy-tabix.
ls_diff-new = <ls_new>.
" SAP function ignores lines that contain only whitespace so we compare directly
" Also check if one line has trailing space(s)
IF ( mv_compare_mode = 1 OR mv_compare_mode = 3 ) AND <ls_old> <> <ls_new>.
IF strlen( condense( <ls_old> ) ) = 0 OR strlen( condense( <ls_new> ) ) = 0.
ls_diff-result = zif_abapgit_definitions=>c_diff-update.
ELSEIF strlen( <ls_old> ) > 0 AND strlen( <ls_new> ) > 0.
lv_last_new = substring( val = <ls_new>
off = strlen( <ls_new> ) - 1 ).
lv_last_old = substring( val = <ls_old>
off = strlen( <ls_old> ) - 1 ).
IF lv_last_new = space OR lv_last_old = space.
ls_diff-result = zif_abapgit_definitions=>c_diff-update.
ENDIF.
ENDIF.
ENDIF.
APPEND ls_diff TO rt_diff.
ENDLOOP.
ENDMETHOD.
METHOD constructor.
DATA: lt_new TYPE rswsourcet,
@ -287,8 +325,8 @@ CLASS zcl_abapgit_diff IMPLEMENTATION.
IMPORTING et_new = lt_new
et_old = lt_old ).
mt_diff = compute_and_render( it_new = lt_new
it_old = lt_old ).
mt_diff = compute_diff( it_new = lt_new
it_old = lt_old ).
adjust_diff( ).

View File

@ -528,12 +528,14 @@ CLASS ltcl_diff IMPLEMENTATION.
add_new( ` ` ). " one space
add_new( ` ` ). " some spaces
add_new( 'E' ).
add_new( 'X' ). " no trailing space
add_old( 'A' ).
add_old( ` ` ). " some spaces
add_old( ` ` ). " two spaces
add_old( `` ). " empty line
add_old( 'E' ).
add_old( `X ` ). " some trailing space
add_expected( iv_new_num = ' 1'
iv_new = 'A'
@ -560,6 +562,11 @@ CLASS ltcl_diff IMPLEMENTATION.
iv_result = zif_abapgit_definitions=>c_diff-unchanged
iv_old_num = ' 5'
iv_old = 'E' ).
add_expected( iv_new_num = ' 6'
iv_new = 'X'
iv_result = zif_abapgit_definitions=>c_diff-update
iv_old_num = ' 6'
iv_old = `X ` ).
test( ).

View File

@ -48,7 +48,8 @@ CLASS ltcl_test IMPLEMENTATION.
DATA lt_objects TYPE zif_abapgit_definitions=>ty_objects_tt.
DATA lt_sha1 TYPE zif_abapgit_git_definitions=>ty_sha1_tt.
INSERT '7bdd8f9f4c6bb0ece461b78c7b559957fad6c3ae' INTO TABLE lt_sha1.
* todo, given the sha1, this test might fail after a year?
INSERT 'e83a31ebafde4e8e7e80ca36662e42e8f20895c5' INTO TABLE lt_sha1.
lt_objects = zcl_abapgit_git_factory=>get_v2_porcelain( )->commits_last_year(
iv_url = 'https://github.com/abapGit/abapGit.git'