new user-exit for validating before pushing into remote (#6013)

Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
Co-authored-by: Marc Bernard <59966492+mbtools@users.noreply.github.com>
This commit is contained in:
Jorge Sancho 2023-02-01 09:46:45 +01:00 committed by GitHub
parent 0f87b87003
commit 49c063998b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 21 deletions

View File

@ -40,12 +40,12 @@ CLASS zcl_abapgit_exit IMPLEMENTATION.
TRY.
gi_exit->adjust_display_commit_url(
EXPORTING
iv_repo_url = iv_repo_url
iv_repo_name = iv_repo_name
iv_repo_key = iv_repo_key
iv_commit_hash = iv_commit_hash
iv_repo_url = iv_repo_url
iv_repo_name = iv_repo_name
iv_repo_key = iv_repo_key
iv_commit_hash = iv_commit_hash
CHANGING
cv_display_url = cv_display_url ).
cv_display_url = cv_display_url ).
CATCH cx_sy_ref_is_initial cx_sy_dyn_call_illegal_method ##NO_HANDLER.
ENDTRY.
ENDIF.
@ -273,8 +273,8 @@ CLASS zcl_abapgit_exit IMPLEMENTATION.
EXPORTING
is_repo_meta = is_repo_meta
CHANGING
ct_local = ct_local
ct_remote = ct_remote ).
ct_local = ct_local
ct_remote = ct_remote ).
CATCH cx_sy_ref_is_initial cx_sy_dyn_call_illegal_method ##NO_HANDLER.
ENDTRY.
ENDIF.
@ -341,4 +341,18 @@ CLASS zcl_abapgit_exit IMPLEMENTATION.
ENDMETHOD.
METHOD zif_abapgit_exit~validate_before_push.
IF gi_exit IS NOT INITIAL.
TRY.
gi_exit->validate_before_push(
is_comment = is_comment
io_stage = io_stage
io_repo = io_repo ).
CATCH cx_sy_ref_is_initial cx_sy_dyn_call_illegal_method ##NO_HANDLER.
ENDTRY.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@ -117,4 +117,13 @@ INTERFACE zif_abapgit_exit
iv_transport_type TYPE zif_abapgit_definitions=>ty_transport_type
CHANGING
cv_transport_request TYPE trkorr.
METHODS validate_before_push
IMPORTING
!is_comment TYPE zif_abapgit_definitions=>ty_comment
!io_stage TYPE REF TO zcl_abapgit_stage
!io_repo TYPE REF TO zcl_abapgit_repo_online
RAISING
zcx_abapgit_exception .
ENDINTERFACE.

View File

@ -172,15 +172,16 @@ CLASS zcl_abapgit_git_porcelain DEFINITION
zcx_abapgit_exception .
CLASS-METHODS create_lightweight_tag
IMPORTING
!is_tag TYPE zif_abapgit_definitions=>ty_git_tag
!iv_url TYPE string
is_tag TYPE zif_abapgit_definitions=>ty_git_tag
iv_url TYPE string
RAISING
zcx_abapgit_exception .
ENDCLASS.
CLASS ZCL_ABAPGIT_GIT_PORCELAIN IMPLEMENTATION.
CLASS zcl_abapgit_git_porcelain IMPLEMENTATION.
METHOD build_trees.
@ -490,7 +491,6 @@ CLASS ZCL_ABAPGIT_GIT_PORCELAIN IMPLEMENTATION.
<ls_updated> LIKE LINE OF rs_result-updated_files,
<ls_exp> LIKE LINE OF lt_expanded.
lt_expanded = full_tree( it_objects = it_old_objects
iv_parent = iv_parent ).
@ -554,9 +554,9 @@ CLASS ZCL_ABAPGIT_GIT_PORCELAIN IMPLEMENTATION.
APPEND LINES OF it_old_objects TO rs_result-new_objects.
walk( EXPORTING it_objects = rs_result-new_objects
iv_sha1 = lv_new_tree
iv_path = '/'
CHANGING ct_files = rs_result-new_files ).
iv_sha1 = lv_new_tree
iv_path = '/'
CHANGING ct_files = rs_result-new_files ).
ENDMETHOD.
@ -744,9 +744,9 @@ CLASS ZCL_ABAPGIT_GIT_PORCELAIN IMPLEMENTATION.
LOOP AT lt_nodes ASSIGNING <ls_node> WHERE chmod = zif_abapgit_definitions=>c_chmod-dir.
CONCATENATE iv_path <ls_node>-name '/' INTO lv_path.
walk( EXPORTING it_objects = it_objects
iv_sha1 = <ls_node>-sha1
iv_path = lv_path
CHANGING ct_files = ct_files ).
iv_sha1 = <ls_node>-sha1
iv_path = lv_path
CHANGING ct_files = ct_files ).
ENDLOOP.
ENDMETHOD.

View File

@ -60,8 +60,8 @@ CLASS zcl_abapgit_services_git IMPLEMENTATION.
li_user = zcl_abapgit_persistence_user=>get_instance( ).
li_user->set_repo_git_user_name( iv_url = io_repo->get_url( )
iv_username = is_commit-committer_name ).
li_user->set_repo_git_user_email( iv_url = io_repo->get_url( )
iv_email = is_commit-committer_email ).
li_user->set_repo_git_user_email( iv_url = io_repo->get_url( )
iv_email = is_commit-committer_email ).
IF is_commit-committer_name IS INITIAL.
zcx_abapgit_exception=>raise( 'Commit: Committer name empty' ).
@ -84,6 +84,11 @@ CLASS zcl_abapgit_services_git IMPLEMENTATION.
INTO ls_comment-comment SEPARATED BY zif_abapgit_definitions=>c_newline.
ENDIF.
zcl_abapgit_exit=>get_instance( )->validate_before_push(
is_comment = ls_comment
io_stage = io_stage
io_repo = io_repo ).
io_repo->push( is_comment = ls_comment
io_stage = io_stage ).
@ -110,8 +115,8 @@ CLASS zcl_abapgit_services_git IMPLEMENTATION.
EXPORTING
iv_source_branch_name = lv_source_branch_name
IMPORTING
ev_name = lv_name
ev_cancel = lv_cancel ).
ev_name = lv_name
ev_cancel = lv_cancel ).
IF lv_cancel = abap_true.
RAISE EXCEPTION TYPE zcx_abapgit_cancel.