From 1fa51e7c0a7c8d0aefb0340b2c64efd398e9e94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=BCnter?= Date: Thu, 27 May 2021 14:54:56 +0200 Subject: [PATCH] Checkout commit: Improve error message (#4793) Checkout commit: Improve error message. Checking out commits is currently limited to branches with less than 99 commits. If this limit is reached a message appears saying 'No commits are available in this branch.'. After this commit is applied the error message is 'Cannot find initial commit. Too many commits. Action not possible.'. --- src/git/zcl_abapgit_git_commit.clas.abap | 53 +++++++++++++----------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/git/zcl_abapgit_git_commit.clas.abap b/src/git/zcl_abapgit_git_commit.clas.abap index a659e9cde..130341c58 100644 --- a/src/git/zcl_abapgit_git_commit.clas.abap +++ b/src/git/zcl_abapgit_git_commit.clas.abap @@ -37,7 +37,9 @@ CLASS zcl_abapgit_git_commit DEFINITION zcx_abapgit_exception . CLASS-METHODS sort_commits CHANGING - !ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt . + !ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt + RAISING + zcx_abapgit_exception . CLASS-METHODS reverse_sort_order CHANGING !ct_commits TYPE zif_abapgit_definitions=>ty_commit_tt . @@ -239,31 +241,32 @@ CLASS zcl_abapgit_git_commit IMPLEMENTATION. " find initial commit READ TABLE ct_commits ASSIGNING WITH KEY parent1 = space. - IF sy-subrc = 0. - - ls_parent-sign = 'I'. - ls_parent-option = 'EQ'. - ls_parent-low = -sha1. - INSERT ls_parent INTO TABLE lt_parents. - - " first commit - INSERT INTO TABLE lt_sorted_commits. - - " remove from available commits - DELETE ct_commits WHERE sha1 = -sha1. - - DO. - get_1st_child_commit( EXPORTING it_commit_sha1s = lt_parents - IMPORTING et_commit_sha1s = lt_parents - es_1st_commit = ls_next_commit - CHANGING ct_commits = ct_commits ). - IF ls_next_commit IS INITIAL. - EXIT. "DO - ENDIF. - INSERT ls_next_commit INTO TABLE lt_sorted_commits. - ENDDO. - + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( |Cannot find initial commit. Too many commits. Action not possible.| ). ENDIF. + + ls_parent-sign = 'I'. + ls_parent-option = 'EQ'. + ls_parent-low = -sha1. + INSERT ls_parent INTO TABLE lt_parents. + + " first commit + INSERT INTO TABLE lt_sorted_commits. + + " remove from available commits + DELETE ct_commits WHERE sha1 = -sha1. + + DO. + get_1st_child_commit( EXPORTING it_commit_sha1s = lt_parents + IMPORTING et_commit_sha1s = lt_parents + es_1st_commit = ls_next_commit + CHANGING ct_commits = ct_commits ). + IF ls_next_commit IS INITIAL. + EXIT. "DO + ENDIF. + INSERT ls_next_commit INTO TABLE lt_sorted_commits. + ENDDO. + ct_commits = lt_sorted_commits. ENDMETHOD.