mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
router: refactor get_page_stage()
(#6362)
This commit is contained in:
parent
1d8af69ae3
commit
a297f1e5cb
|
@ -308,60 +308,44 @@ CLASS zcl_abapgit_gui_router IMPLEMENTATION.
|
|||
|
||||
METHOD get_page_stage.
|
||||
|
||||
DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
||||
lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
|
||||
lv_seed TYPE string,
|
||||
lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage,
|
||||
lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp,
|
||||
lv_answer TYPE c LENGTH 1,
|
||||
lv_question_text TYPE string,
|
||||
lv_question_title TYPE string,
|
||||
lv_show_create_branch_popup TYPE c LENGTH 1,
|
||||
lx_error TYPE REF TO cx_sy_move_cast_error.
|
||||
DATA: lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
||||
lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
|
||||
lv_seed TYPE string,
|
||||
lo_stage_page TYPE REF TO zcl_abapgit_gui_page_stage,
|
||||
lo_code_inspector_page TYPE REF TO zcl_abapgit_gui_page_code_insp,
|
||||
lv_sci_result TYPE zif_abapgit_definitions=>ty_sci_result,
|
||||
lx_error TYPE REF TO cx_sy_move_cast_error.
|
||||
|
||||
lv_key = ii_event->query( )->get( 'KEY' ).
|
||||
lv_seed = ii_event->query( )->get( 'SEED' ).
|
||||
|
||||
lv_sci_result = zif_abapgit_definitions=>c_sci_result-no_run.
|
||||
|
||||
TRY.
|
||||
lo_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).
|
||||
CATCH cx_sy_move_cast_error INTO lx_error.
|
||||
zcx_abapgit_exception=>raise( `Staging is only possible for online repositories.` ).
|
||||
ENDTRY.
|
||||
|
||||
IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL.
|
||||
IF lo_repo->get_selected_branch( ) CP zif_abapgit_definitions=>c_git_branch-tags.
|
||||
zcx_abapgit_exception=>raise( |You are working on a tag, must be on branch| ).
|
||||
ELSEIF lo_repo->get_selected_commit( ) IS NOT INITIAL.
|
||||
zcx_abapgit_exception=>raise( |You are working on a commit, must be on branch| ).
|
||||
ENDIF.
|
||||
|
||||
IF lo_repo->get_local_settings( )-code_inspector_check_variant IS NOT INITIAL.
|
||||
CREATE OBJECT lo_code_inspector_page
|
||||
EXPORTING
|
||||
io_repo = lo_repo.
|
||||
|
||||
IF lo_code_inspector_page->is_nothing_to_display( ) = abap_true.
|
||||
" force refresh on stage, to make sure the latest local and remote files are used
|
||||
lo_repo->refresh( ).
|
||||
CREATE OBJECT lo_stage_page
|
||||
EXPORTING
|
||||
io_repo = lo_repo
|
||||
iv_seed = lv_seed
|
||||
iv_sci_result = zif_abapgit_definitions=>c_sci_result-passed
|
||||
ii_obj_filter = ii_obj_filter.
|
||||
|
||||
ri_page = lo_stage_page.
|
||||
lv_sci_result = zif_abapgit_definitions=>c_sci_result-passed.
|
||||
ELSE.
|
||||
ri_page = lo_code_inspector_page.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
ELSEIF lo_repo->get_selected_branch( ) CP zif_abapgit_definitions=>c_git_branch-tags.
|
||||
lv_show_create_branch_popup = abap_true.
|
||||
lv_question_title = 'Staging on a tag'.
|
||||
lv_question_text = 'You are currently working on a tag.'.
|
||||
lv_question_text = |{ lv_question_text } You must be on a branch to stage.|.
|
||||
lv_question_text = |{ lv_question_text } Create new branch?|.
|
||||
ELSEIF lo_repo->get_selected_commit( ) IS NOT INITIAL.
|
||||
lv_show_create_branch_popup = abap_true.
|
||||
lv_question_title = 'Staging on a checked out commit'.
|
||||
lv_question_text = 'You are currently checked out in a commit.'.
|
||||
lv_question_text = |{ lv_question_text } You must be on a branch to stage.|.
|
||||
lv_question_text = |{ lv_question_text } Create new branch?|.
|
||||
ELSE.
|
||||
|
||||
IF ri_page IS INITIAL.
|
||||
" force refresh on stage, to make sure the latest local and remote files are used
|
||||
lo_repo->refresh( ).
|
||||
|
||||
|
@ -369,33 +353,10 @@ CLASS zcl_abapgit_gui_router IMPLEMENTATION.
|
|||
EXPORTING
|
||||
io_repo = lo_repo
|
||||
iv_seed = lv_seed
|
||||
iv_sci_result = lv_sci_result
|
||||
ii_obj_filter = ii_obj_filter.
|
||||
|
||||
ri_page = lo_stage_page.
|
||||
|
||||
ENDIF.
|
||||
|
||||
IF lv_show_create_branch_popup = abap_true.
|
||||
|
||||
lv_answer = zcl_abapgit_ui_factory=>get_popups( )->popup_to_confirm(
|
||||
iv_titlebar = lv_question_title
|
||||
iv_text_question = lv_question_text
|
||||
iv_text_button_1 = 'New branch' "Ideally the button name would be Create branch, but it did not fit
|
||||
iv_icon_button_1 = 'ICON_OKAY'
|
||||
iv_text_button_2 = 'Cancel'
|
||||
iv_icon_button_2 = 'ICON_CANCEL'
|
||||
iv_default_button = '2'
|
||||
iv_display_cancel_button = abap_false ).
|
||||
IF lv_answer = '1'.
|
||||
TRY.
|
||||
zcl_abapgit_services_git=>create_branch( iv_key = lo_repo->get_key( ) ).
|
||||
CATCH zcx_abapgit_cancel.
|
||||
"Continue processing so we can return to the correct page
|
||||
ENDTRY.
|
||||
ENDIF.
|
||||
|
||||
ri_page = zcl_abapgit_gui_page_repo_view=>create( lo_repo->get_key( ) ).
|
||||
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
|
Loading…
Reference in New Issue
Block a user