mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 04:36:49 +08:00
Create branch: Add existence check (#4794)
Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
5f4eb56071
commit
f97320f1dc
|
@ -59,6 +59,11 @@ CLASS zcl_abapgit_repo_online DEFINITION
|
||||||
VALUE(rt_objects) TYPE zif_abapgit_definitions=>ty_objects_tt
|
VALUE(rt_objects) TYPE zif_abapgit_definitions=>ty_objects_tt
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
zcx_abapgit_exception .
|
||||||
|
METHODS raise_error_if_branch_exists
|
||||||
|
IMPORTING
|
||||||
|
iv_name TYPE string
|
||||||
|
RAISING
|
||||||
|
zcx_abapgit_exception.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +180,8 @@ CLASS zcl_abapgit_repo_online IMPLEMENTATION.
|
||||||
lv_sha1 = iv_from.
|
lv_sha1 = iv_from.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
raise_error_if_branch_exists( iv_name ).
|
||||||
|
|
||||||
zcl_abapgit_git_porcelain=>create_branch(
|
zcl_abapgit_git_porcelain=>create_branch(
|
||||||
iv_url = get_url( )
|
iv_url = get_url( )
|
||||||
iv_name = iv_name
|
iv_name = iv_name
|
||||||
|
@ -324,4 +331,23 @@ CLASS zcl_abapgit_repo_online IMPLEMENTATION.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD raise_error_if_branch_exists.
|
||||||
|
|
||||||
|
DATA:
|
||||||
|
lt_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt,
|
||||||
|
lv_display_name TYPE string.
|
||||||
|
|
||||||
|
lt_branches = zcl_abapgit_git_transport=>branches( get_url( ) )->get_branches_only( ).
|
||||||
|
|
||||||
|
READ TABLE lt_branches WITH TABLE KEY name_key
|
||||||
|
COMPONENTS name = iv_name
|
||||||
|
TRANSPORTING NO FIELDS.
|
||||||
|
IF sy-subrc = 0.
|
||||||
|
lv_display_name = zcl_abapgit_git_branch_list=>get_display_name( iv_name ).
|
||||||
|
zcx_abapgit_exception=>raise( |Branch '{ lv_display_name }' already exists| ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -42,7 +42,9 @@ INTERFACE zif_abapgit_definitions
|
||||||
display_name TYPE string,
|
display_name TYPE string,
|
||||||
END OF ty_git_branch .
|
END OF ty_git_branch .
|
||||||
TYPES:
|
TYPES:
|
||||||
ty_git_branch_list_tt TYPE STANDARD TABLE OF ty_git_branch WITH DEFAULT KEY .
|
ty_git_branch_list_tt TYPE STANDARD TABLE OF ty_git_branch WITH DEFAULT KEY
|
||||||
|
WITH NON-UNIQUE SORTED KEY name_key
|
||||||
|
COMPONENTS name.
|
||||||
TYPES:
|
TYPES:
|
||||||
BEGIN OF ty_git_tag,
|
BEGIN OF ty_git_tag,
|
||||||
sha1 TYPE ty_sha1,
|
sha1 TYPE ty_sha1,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user