mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Limit size of branch overview (#4726)
* Add support for partial logs (WIP) * Still trying to handle multiple branch origins * Error message for too many commits * Remove PDXX * Lint Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
7b336a4a71
commit
788d649feb
|
@ -41,6 +41,7 @@ CLASS zcl_abapgit_git_commit DEFINITION
|
||||||
CLASS-METHODS reverse_sort_order
|
CLASS-METHODS reverse_sort_order
|
||||||
CHANGING
|
CHANGING
|
||||||
!ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt .
|
!ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt .
|
||||||
|
CLASS-METHODS clear_missing_parents CHANGING ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt .
|
||||||
|
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
|
@ -55,6 +56,13 @@ CLASS zcl_abapgit_git_commit DEFINITION
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt .
|
ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt .
|
||||||
|
|
||||||
|
CLASS-METHODS is_missing
|
||||||
|
IMPORTING
|
||||||
|
it_commits TYPE zif_abapgit_definitions=>ty_commit_tt
|
||||||
|
iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1
|
||||||
|
RETURNING
|
||||||
|
VALUE(rv_result) TYPE abap_bool.
|
||||||
|
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
@ -255,8 +263,45 @@ CLASS zcl_abapgit_git_commit IMPLEMENTATION.
|
||||||
INSERT ls_next_commit INTO TABLE lt_sorted_commits.
|
INSERT ls_next_commit INTO TABLE lt_sorted_commits.
|
||||||
ENDDO.
|
ENDDO.
|
||||||
|
|
||||||
|
ENDIF.
|
||||||
ct_commits = lt_sorted_commits.
|
ct_commits = lt_sorted_commits.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD clear_missing_parents.
|
||||||
|
|
||||||
|
"Part of #4719 to handle cut commit sequences, todo
|
||||||
|
|
||||||
|
FIELD-SYMBOLS: <ls_commit> TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
|
||||||
|
LOOP AT ct_commits ASSIGNING <ls_commit>.
|
||||||
|
|
||||||
|
IF is_missing( it_commits = ct_commits
|
||||||
|
iv_sha1 = <ls_commit>-parent1 ) = abap_true.
|
||||||
|
CLEAR <ls_commit>-parent1.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
IF is_missing( it_commits = ct_commits
|
||||||
|
iv_sha1 = <ls_commit>-parent2 ) = abap_true.
|
||||||
|
CLEAR <ls_commit>-parent2.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDLOOP.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD is_missing.
|
||||||
|
|
||||||
|
IF iv_sha1 IS NOT INITIAL.
|
||||||
|
|
||||||
|
READ TABLE it_commits
|
||||||
|
TRANSPORTING NO FIELDS
|
||||||
|
WITH KEY sha1 = iv_sha1.
|
||||||
|
rv_result = boolc( sy-subrc <> 0 ).
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -100,3 +100,117 @@ CLASS ltcl_test IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltc_parent_handling DEFINITION DEFERRED.
|
||||||
|
CLASS zcl_abapgit_git_commit DEFINITION LOCAL FRIENDS ltc_parent_handling.
|
||||||
|
CLASS ltc_parent_handling DEFINITION FINAL FOR TESTING
|
||||||
|
DURATION SHORT
|
||||||
|
RISK LEVEL HARMLESS.
|
||||||
|
|
||||||
|
PRIVATE SECTION.
|
||||||
|
DATA mt_commits TYPE zif_abapgit_definitions=>ty_commit_tt.
|
||||||
|
METHODS blank_not_missing FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS parent_is_missing FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS parent_is_found FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS missing_parent1_cleared FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS missing_parent2_cleared FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS matched_parent1_remains FOR TESTING RAISING cx_static_check.
|
||||||
|
METHODS given_commit_sha1 IMPORTING iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1.
|
||||||
|
METHODS parent_should_be_missing IMPORTING iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1.
|
||||||
|
METHODS parent_should_not_be_missing IMPORTING iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1.
|
||||||
|
METHODS given_commit IMPORTING iv_sha1 TYPE zif_abapgit_definitions=>ty_sha1
|
||||||
|
iv_parent1 TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL
|
||||||
|
iv_parent2 TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
CLASS ltc_parent_handling IMPLEMENTATION.
|
||||||
|
|
||||||
|
METHOD blank_not_missing.
|
||||||
|
given_commit_sha1( 'F00' ).
|
||||||
|
parent_should_not_be_missing( '' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD parent_is_missing.
|
||||||
|
given_commit_sha1( 'F00' ).
|
||||||
|
parent_should_be_missing( 'BA5' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD parent_is_found.
|
||||||
|
given_commit_sha1( 'F00' ).
|
||||||
|
parent_should_not_be_missing( 'F00' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD missing_parent1_cleared.
|
||||||
|
|
||||||
|
DATA ls_commit TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
|
||||||
|
given_commit( iv_sha1 = 'F00'
|
||||||
|
iv_parent1 = 'BA5' ).
|
||||||
|
zcl_abapgit_git_commit=>clear_missing_parents( CHANGING ct_commits = mt_commits ).
|
||||||
|
|
||||||
|
READ TABLE mt_commits INDEX 1 INTO ls_commit.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = ls_commit-parent1
|
||||||
|
exp = '' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD missing_parent2_cleared.
|
||||||
|
|
||||||
|
DATA ls_commit TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
|
||||||
|
given_commit( iv_sha1 = 'F00'
|
||||||
|
iv_parent2 = 'BA5' ).
|
||||||
|
zcl_abapgit_git_commit=>clear_missing_parents( CHANGING ct_commits = mt_commits ).
|
||||||
|
|
||||||
|
READ TABLE mt_commits INDEX 1 INTO ls_commit.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = ls_commit-parent2
|
||||||
|
exp = '' ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD matched_parent1_remains.
|
||||||
|
|
||||||
|
DATA ls_commit TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
|
||||||
|
given_commit( iv_sha1 = 'F00' ).
|
||||||
|
given_commit( iv_sha1 = 'BA5'
|
||||||
|
iv_parent1 = 'F00' ).
|
||||||
|
|
||||||
|
zcl_abapgit_git_commit=>clear_missing_parents( CHANGING ct_commits = mt_commits ).
|
||||||
|
|
||||||
|
READ TABLE mt_commits INDEX 2 INTO ls_commit.
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = ls_commit-parent1
|
||||||
|
exp = 'F00' ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_commit_sha1.
|
||||||
|
DATA ls_commit TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
|
||||||
|
ls_commit-sha1 = iv_sha1.
|
||||||
|
APPEND ls_commit TO mt_commits.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD parent_should_be_missing.
|
||||||
|
cl_abap_unit_assert=>assert_true(
|
||||||
|
zcl_abapgit_git_commit=>is_missing( it_commits = mt_commits
|
||||||
|
iv_sha1 = iv_sha1 ) ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD parent_should_not_be_missing.
|
||||||
|
cl_abap_unit_assert=>assert_false(
|
||||||
|
zcl_abapgit_git_commit=>is_missing( it_commits = mt_commits
|
||||||
|
iv_sha1 = iv_sha1 ) ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_commit.
|
||||||
|
FIELD-SYMBOLS: <ls_commit> TYPE zif_abapgit_definitions=>ty_commit.
|
||||||
|
APPEND INITIAL LINE TO mt_commits ASSIGNING <ls_commit>.
|
||||||
|
<ls_commit>-sha1 = iv_sha1.
|
||||||
|
<ls_commit>-parent1 = iv_parent1.
|
||||||
|
<ls_commit>-parent2 = iv_parent2.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
|
|
@ -244,7 +244,7 @@ CLASS ZCL_ABAPGIT_GIT_PACK IMPLEMENTATION.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ELSEIF lv_zlib = c_zlib_hmm.
|
ELSEIF lv_zlib = c_zlib_hmm.
|
||||||
* cl_abap_gzip copmression works for header '789C', but does not work for
|
* cl_abap_gzip compression works for header '789C', but does not work for
|
||||||
* '7801', call custom implementation of DEFLATE algorithm.
|
* '7801', call custom implementation of DEFLATE algorithm.
|
||||||
* The custom implementation could handle both, but most likely the kernel
|
* The custom implementation could handle both, but most likely the kernel
|
||||||
* implementation runs faster than the custom ABAP.
|
* implementation runs faster than the custom ABAP.
|
||||||
|
|
|
@ -101,7 +101,7 @@ ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_ABAPGIT_GIT_TRANSPORT IMPLEMENTATION.
|
CLASS zcl_abapgit_git_transport IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD branches.
|
METHOD branches.
|
||||||
|
|
|
@ -50,11 +50,14 @@ CLASS zcl_abapgit_branch_overview DEFINITION
|
||||||
METHODS determine_tags
|
METHODS determine_tags
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
zcx_abapgit_exception .
|
||||||
|
METHODS get_deepen_level
|
||||||
|
RETURNING
|
||||||
|
VALUE(rv_result) TYPE i.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_ABAPGIT_BRANCH_OVERVIEW IMPLEMENTATION.
|
CLASS zcl_abapgit_branch_overview IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD compress_internal.
|
METHOD compress_internal.
|
||||||
|
@ -91,6 +94,9 @@ CLASS ZCL_ABAPGIT_BRANCH_OVERVIEW IMPLEMENTATION.
|
||||||
lt_objects = get_git_objects( io_repo ).
|
lt_objects = get_git_objects( io_repo ).
|
||||||
|
|
||||||
mt_commits = zcl_abapgit_git_commit=>parse_commits( lt_objects ).
|
mt_commits = zcl_abapgit_git_commit=>parse_commits( lt_objects ).
|
||||||
|
IF lines( mt_commits ) > 2000.
|
||||||
|
zcx_abapgit_exception=>raise( 'Too many commits to display overview' ).
|
||||||
|
ENDIF.
|
||||||
zcl_abapgit_git_commit=>sort_commits( CHANGING ct_commits = mt_commits ).
|
zcl_abapgit_git_commit=>sort_commits( CHANGING ct_commits = mt_commits ).
|
||||||
|
|
||||||
parse_annotated_tags( lt_objects ).
|
parse_annotated_tags( lt_objects ).
|
||||||
|
@ -335,7 +341,7 @@ CLASS ZCL_ABAPGIT_BRANCH_OVERVIEW IMPLEMENTATION.
|
||||||
EXPORTING
|
EXPORTING
|
||||||
iv_url = io_repo->get_url( )
|
iv_url = io_repo->get_url( )
|
||||||
iv_branch_name = io_repo->get_selected_branch( )
|
iv_branch_name = io_repo->get_selected_branch( )
|
||||||
iv_deepen_level = 0
|
iv_deepen_level = get_deepen_level( )
|
||||||
it_branches = lt_branches_and_tags
|
it_branches = lt_branches_and_tags
|
||||||
IMPORTING
|
IMPORTING
|
||||||
et_objects = rt_objects ).
|
et_objects = rt_objects ).
|
||||||
|
@ -446,4 +452,19 @@ CLASS ZCL_ABAPGIT_BRANCH_OVERVIEW IMPLEMENTATION.
|
||||||
rt_tags = mt_tags.
|
rt_tags = mt_tags.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD get_deepen_level.
|
||||||
|
|
||||||
|
DATA: lv_deepen_level(10) TYPE c.
|
||||||
|
|
||||||
|
"Experimental: Use STVARV to get a locally configured value
|
||||||
|
SELECT SINGLE low
|
||||||
|
INTO lv_deepen_level
|
||||||
|
FROM tvarvc
|
||||||
|
WHERE name = 'ABAPGIT_TEST_LOG_LENGTH' ##WARN_OK.
|
||||||
|
|
||||||
|
rv_result = lv_deepen_level.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user