mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 11:46:38 +08:00
create_branch refactored
This commit is contained in:
parent
04edb0a455
commit
1d035cf1ab
|
@ -140,18 +140,7 @@ CLASS ZCL_ABAPGIT_SERVICES_GIT IMPLEMENTATION.
|
|||
RAISE EXCEPTION TYPE zcx_abapgit_cancel.
|
||||
ENDIF.
|
||||
|
||||
****************
|
||||
* TODO: move this part to ONLINE repo class
|
||||
ASSERT lv_name CP 'refs/heads/+*'.
|
||||
|
||||
zcl_abapgit_git_porcelain=>create_branch(
|
||||
iv_url = lo_repo->get_url( )
|
||||
iv_name = lv_name
|
||||
iv_from = lo_repo->get_sha1_remote( ) ).
|
||||
|
||||
" automatically switch to new branch
|
||||
lo_repo->set_branch_name( lv_name ).
|
||||
*****************
|
||||
lo_repo->create_branch( lv_name ).
|
||||
|
||||
MESSAGE 'Switched to new branch' TYPE 'S' ##NO_TEXT.
|
||||
|
||||
|
|
|
@ -66,6 +66,12 @@ CLASS zcl_abapgit_repo_online DEFINITION
|
|||
VALUE(rt_unnecessary_local_objects) TYPE zif_abapgit_definitions=>ty_tadir_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS create_branch
|
||||
IMPORTING
|
||||
!iv_name TYPE string
|
||||
!iv_from TYPE zif_abapgit_definitions=>ty_sha1 OPTIONAL
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
|
||||
METHODS deserialize
|
||||
REDEFINITION .
|
||||
|
@ -107,6 +113,29 @@ CLASS ZCL_ABAPGIT_REPO_ONLINE IMPLEMENTATION.
|
|||
ENDMETHOD. "constructor
|
||||
|
||||
|
||||
METHOD create_branch.
|
||||
|
||||
DATA: lv_sha1 TYPE zif_abapgit_definitions=>ty_sha1.
|
||||
|
||||
ASSERT iv_name CP 'refs/heads/+*'.
|
||||
|
||||
IF iv_from IS INITIAL.
|
||||
lv_sha1 = get_sha1_remote( ).
|
||||
ELSE.
|
||||
lv_sha1 = iv_from.
|
||||
ENDIF.
|
||||
|
||||
zcl_abapgit_git_porcelain=>create_branch(
|
||||
iv_url = get_url( )
|
||||
iv_name = iv_name
|
||||
iv_from = lv_sha1 ).
|
||||
|
||||
" automatically switch to new branch
|
||||
set_branch_name( iv_name ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD deserialize.
|
||||
|
||||
initialize( ).
|
||||
|
|
|
@ -7,28 +7,22 @@ CLASS zcl_abapgit_transport_2_branch DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|||
is_transport_to_branch TYPE zif_abapgit_definitions=>ty_transport_to_branch
|
||||
it_transport_objects TYPE scts_tadir
|
||||
RAISING zcx_abapgit_exception.
|
||||
PRIVATE SECTION.
|
||||
PROTECTED SECTION.
|
||||
|
||||
METHODS create_new_branch
|
||||
IMPORTING
|
||||
io_repository TYPE REF TO zcl_abapgit_repo_online
|
||||
iv_branch_name TYPE string
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
METHODS generate_commit_message
|
||||
IMPORTING
|
||||
is_transport_to_branch TYPE zif_abapgit_definitions=>ty_transport_to_branch
|
||||
!is_transport_to_branch TYPE zif_abapgit_definitions=>ty_transport_to_branch
|
||||
RETURNING
|
||||
VALUE(rs_comment) TYPE zif_abapgit_definitions=>ty_comment.
|
||||
VALUE(rs_comment) TYPE zif_abapgit_definitions=>ty_comment .
|
||||
METHODS stage_transport_objects
|
||||
IMPORTING
|
||||
it_transport_objects TYPE scts_tadir
|
||||
io_stage TYPE REF TO zcl_abapgit_stage
|
||||
is_stage_objects TYPE zif_abapgit_definitions=>ty_stage_files
|
||||
it_object_statuses TYPE zif_abapgit_definitions=>ty_results_tt
|
||||
!it_transport_objects TYPE scts_tadir
|
||||
!io_stage TYPE REF TO zcl_abapgit_stage
|
||||
!is_stage_objects TYPE zif_abapgit_definitions=>ty_stage_files
|
||||
!it_object_statuses TYPE zif_abapgit_definitions=>ty_results_tt
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
|
||||
zcx_abapgit_exception .
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
@ -47,13 +41,11 @@ CLASS ZCL_ABAPGIT_TRANSPORT_2_BRANCH IMPLEMENTATION.
|
|||
lv_branch_name = zcl_abapgit_git_branch_list=>complete_heads_branch_name(
|
||||
zcl_abapgit_git_branch_list=>normalize_branch_name( is_transport_to_branch-branch_name ) ).
|
||||
|
||||
create_new_branch(
|
||||
io_repository = io_repository
|
||||
iv_branch_name = lv_branch_name ).
|
||||
io_repository->create_branch( lv_branch_name ).
|
||||
|
||||
CREATE OBJECT lo_stage
|
||||
EXPORTING
|
||||
iv_branch_name = lv_branch_name
|
||||
iv_branch_name = io_repository->get_branch_name( )
|
||||
iv_branch_sha1 = io_repository->get_sha1_remote( ).
|
||||
|
||||
ls_stage_objects = zcl_abapgit_stage_logic=>get( io_repository ).
|
||||
|
@ -73,21 +65,6 @@ CLASS ZCL_ABAPGIT_TRANSPORT_2_BRANCH IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD create_new_branch.
|
||||
ASSERT iv_branch_name CP 'refs/heads/+*'.
|
||||
TRY.
|
||||
zcl_abapgit_git_porcelain=>create_branch(
|
||||
iv_url = io_repository->get_url( )
|
||||
iv_name = iv_branch_name
|
||||
iv_from = io_repository->get_sha1_remote( ) ).
|
||||
|
||||
io_repository->set_branch_name( iv_branch_name ).
|
||||
CATCH zcx_abapgit_exception.
|
||||
zcx_abapgit_exception=>raise( 'Error when creating new branch').
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD generate_commit_message.
|
||||
rs_comment-committer-name = sy-uname.
|
||||
rs_comment-committer-email = |{ rs_comment-committer-name }@localhost|.
|
||||
|
|
Loading…
Reference in New Issue
Block a user