Improve secondary key access (#4801)

This commit is contained in:
Christian Günter 2021-05-31 07:47:30 +02:00 committed by GitHub
parent ad244abacd
commit 53dec3d2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -127,7 +127,8 @@ CLASS zcl_abapgit_git_branch_list IMPLEMENTATION.
ELSE. ELSE.
READ TABLE mt_branches INTO rs_branch READ TABLE mt_branches INTO rs_branch
WITH KEY name = iv_branch_name. WITH TABLE KEY name_key
COMPONENTS name = iv_branch_name.
IF sy-subrc <> 0. IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( |Branch { get_display_name( iv_branch_name ) zcx_abapgit_exception=>raise( |Branch { get_display_name( iv_branch_name )
} not found. Use 'Branch' > 'Switch' to select a different branch| ). } not found. Use 'Branch' > 'Switch' to select a different branch| ).
@ -145,11 +146,13 @@ CLASS zcl_abapgit_git_branch_list IMPLEMENTATION.
lv_branch_name = iv_branch_name && '^{}'. lv_branch_name = iv_branch_name && '^{}'.
READ TABLE mt_branches INTO rs_branch READ TABLE mt_branches INTO rs_branch
WITH KEY name = lv_branch_name. WITH TABLE KEY name_key
COMPONENTS name = lv_branch_name.
IF sy-subrc <> 0. IF sy-subrc <> 0.
READ TABLE mt_branches INTO rs_branch READ TABLE mt_branches INTO rs_branch
WITH KEY name = iv_branch_name. WITH TABLE KEY name_key
COMPONENTS name = iv_branch_name.
IF sy-subrc <> 0. IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( 'Branch not found' ). zcx_abapgit_exception=>raise( 'Branch not found' ).
ENDIF. ENDIF.

View File

@ -45,7 +45,9 @@ CLASS ltcl_parse IMPLEMENTATION.
act = lines( lt_list ) act = lines( lt_list )
exp = iv_expected_lines ). exp = iv_expected_lines ).
READ TABLE lt_list WITH KEY name = zif_abapgit_definitions=>c_git_branch-main TRANSPORTING NO FIELDS. READ TABLE lt_list WITH TABLE KEY name_key
COMPONENTS name = zif_abapgit_definitions=>c_git_branch-main
TRANSPORTING NO FIELDS.
cl_abap_unit_assert=>assert_subrc( ). cl_abap_unit_assert=>assert_subrc( ).
ENDMETHOD. ENDMETHOD.

View File

@ -132,7 +132,8 @@ CLASS zcl_abapgit_branch_overview IMPLEMENTATION.
* Exchange HEAD, and make sure the branch determination starts with the HEAD branch * Exchange HEAD, and make sure the branch determination starts with the HEAD branch
READ TABLE mt_branches ASSIGNING <ls_head> WITH KEY name = lc_head. READ TABLE mt_branches ASSIGNING <ls_head>
WITH TABLE KEY name_key COMPONENTS name = lc_head.
ASSERT sy-subrc = 0. ASSERT sy-subrc = 0.
LOOP AT mt_branches ASSIGNING <ls_branch> LOOP AT mt_branches ASSIGNING <ls_branch>
WHERE sha1 = <ls_head>-sha1 AND name <> lc_head. WHERE sha1 = <ls_head>-sha1 AND name <> lc_head.