mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
route, popups, services (#342)
* #319, btw: decrease short list size, fix db exept * #319 refactor popup_to_confirm * #338 small fixes * #338 lcl_services_repo, part1 * #338, remove files_commit action logic Removes files_commit action handling and lcl_zip->files_commit and modifies interface of lcl_zip->export * #338, services_repo fixes and improvements * #338, lcl_services_abapgit * #338, small improvements * #338 adopt render_repo_menu from #319 * #338 lcx_cancel * #338 zip services * #338 abapgit services finetune * #338 lcx_cancel finetune * #338 zip finetune * #388 small adj * #338 lcl_services_git part1 * #338 lcl_services_db, html_actions features * #338, services_repo=>new_offline * #338, delete/switch branch to lcl_services_git * #338, improvements in switch_branch * #338, switch_branch more improvements
This commit is contained in:
parent
094266e4f7
commit
7719fa3d44
|
@ -56,16 +56,17 @@ INCLUDE zabapgit_git.
|
|||
INCLUDE zabapgit_objects.
|
||||
INCLUDE zabapgit_tadir.
|
||||
INCLUDE zabapgit_file_status.
|
||||
INCLUDE zabapgit_popups.
|
||||
INCLUDE zabapgit_zip.
|
||||
INCLUDE zabapgit_objects_impl.
|
||||
|
||||
INCLUDE zabapgit_object_serializing. " All serializing classes here
|
||||
|
||||
INCLUDE zabapgit_repo_impl.
|
||||
INCLUDE zabapgit_background.
|
||||
INCLUDE zabapgit_zip.
|
||||
INCLUDE zabapgit_transport.
|
||||
INCLUDE zabapgit_popups.
|
||||
|
||||
INCLUDE zabapgit_services. " All services here
|
||||
INCLUDE zabapgit_gui_pages. " All GUI pages here
|
||||
INCLUDE zabapgit_gui_router.
|
||||
INCLUDE zabapgit_gui.
|
||||
|
|
|
@ -132,7 +132,28 @@ CONSTANTS: gc_newline TYPE abap_char1 VALUE cl_abap_char_utilities=>newline.
|
|||
|
||||
CONSTANTS: gc_english TYPE spras VALUE 'E'.
|
||||
|
||||
CONSTANTS: gc_abapgit_homepage TYPE string VALUE 'http://www.abapgit.org' ##NO_TEXT.
|
||||
|
||||
CONSTANTS: gc_root_dir TYPE string VALUE '/',
|
||||
gc_dot_abapgit TYPE string VALUE '.abapgit.xml' ##NO_TEXT.
|
||||
gc_dot_abapgit TYPE string VALUE '.abapgit.xml' ##NO_TEXT.
|
||||
|
||||
CONSTANTS: BEGIN OF gc_action,
|
||||
repo_clone TYPE string VALUE 'repo_clone',
|
||||
repo_refresh TYPE string VALUE 'repo_refresh',
|
||||
repo_remove TYPE string VALUE 'repo_remove',
|
||||
repo_purge TYPE string VALUE 'repo_purge',
|
||||
repo_newoffline TYPE string VALUE 'repo_newoffline',
|
||||
abapgit_home TYPE string VALUE 'abapgit_home',
|
||||
abapgit_install TYPE string VALUE 'abapgit_install',
|
||||
zip_import TYPE string VALUE 'zip_import',
|
||||
zip_export TYPE string VALUE 'zip_export',
|
||||
zip_package TYPE string VALUE 'zip_package',
|
||||
zip_transport TYPE string VALUE 'zip_transport',
|
||||
git_pull TYPE string VALUE 'git_pull',
|
||||
git_reset TYPE string VALUE 'git_reset',
|
||||
git_branch_create TYPE string VALUE 'git_branch_create',
|
||||
git_branch_switch TYPE string VALUE 'git_branch_switch',
|
||||
git_branch_delete TYPE string VALUE 'git_branch_delete',
|
||||
db_delete TYPE string VALUE 'db_delete',
|
||||
db_update TYPE string VALUE 'db_update',
|
||||
db_display TYPE string VALUE 'db_display',
|
||||
db_edit TYPE string VALUE 'db_edit',
|
||||
END OF gc_action.
|
|
@ -5,8 +5,6 @@
|
|||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_EXCEPTION DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_exception DEFINITION INHERITING FROM cx_static_check FINAL.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
@ -27,8 +25,6 @@ ENDCLASS. "CX_LOCAL_EXCEPTION DEFINITION
|
|||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_EXCEPTION IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_exception IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
|
@ -48,8 +44,6 @@ ENDCLASS. "lcx_exception IMPLEMENTATION
|
|||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_NOT_FOUND DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_not_found DEFINITION INHERITING FROM cx_static_check FINAL.
|
||||
|
||||
ENDCLASS. "CX_LOCAL_EXCEPTION DEFINITION
|
||||
|
@ -57,8 +51,20 @@ ENDCLASS. "CX_LOCAL_EXCEPTION DEFINITION
|
|||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_NOT_FOUND IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
*
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_not_found IMPLEMENTATION.
|
||||
|
||||
ENDCLASS. "lcx_not_found IMPLEMENTATION
|
||||
ENDCLASS. "lcx_not_found IMPLEMENTATION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_CANCEL DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_cancel DEFINITION INHERITING FROM cx_static_check FINAL.
|
||||
|
||||
ENDCLASS. "lcx_cancel DEFINITION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS LCX_CANCEL IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcx_cancel IMPLEMENTATION.
|
||||
|
||||
ENDCLASS. "lcx_cancel IMPLEMENTATION
|
|
@ -125,6 +125,8 @@ CLASS lcl_gui IMPLEMENTATION.
|
|||
CATCH lcx_exception INTO lx_exception.
|
||||
ROLLBACK WORK.
|
||||
MESSAGE lx_exception->mv_text TYPE 'S' DISPLAY LIKE 'E'.
|
||||
CATCH lcx_cancel ##NO_HANDLER.
|
||||
" Do nothing = gc_event_state-no_more_act
|
||||
ENDTRY.
|
||||
|
||||
ENDMETHOD. "on_event
|
||||
|
|
|
@ -15,7 +15,7 @@ CLASS lcl_gui_router DEFINITION FINAL.
|
|||
it_postdata TYPE cnht_post_data_tab OPTIONAL
|
||||
EXPORTING ei_page TYPE REF TO lif_gui_page
|
||||
ev_state TYPE i
|
||||
RAISING lcx_exception.
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
|
@ -45,35 +45,9 @@ CLASS lcl_gui_router DEFINITION FINAL.
|
|||
RETURNING VALUE(ri_page) TYPE REF TO lif_gui_page
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS abapgit_installation
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS repo_purge
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS repo_remove
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS repo_pull
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS reset
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS create_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS db_delete
|
||||
IMPORTING iv_getdata TYPE clike
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS db_save
|
||||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
METHODS get_page_background
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RETURNING VALUE(ri_page) TYPE REF TO lif_gui_page
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
@ -85,10 +59,13 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
|
||||
METHOD on_event.
|
||||
|
||||
DATA: lv_url TYPE string,
|
||||
lv_key TYPE lcl_persistence_repo=>ty_repo-key,
|
||||
ls_item TYPE ty_item.
|
||||
DATA: lv_url TYPE string,
|
||||
lv_key TYPE lcl_persistence_repo=>ty_repo-key,
|
||||
ls_db TYPE lcl_persistence_db=>ty_content,
|
||||
ls_item TYPE ty_item.
|
||||
|
||||
lv_key = iv_getdata. " TODO refactor
|
||||
lv_url = iv_getdata. " TODO refactor
|
||||
|
||||
CASE iv_action.
|
||||
" General routing
|
||||
|
@ -99,21 +76,8 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
ei_page = get_page_by_name( iv_action ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
WHEN 'background'.
|
||||
lv_key = iv_getdata.
|
||||
CREATE OBJECT ei_page TYPE lcl_gui_page_background
|
||||
EXPORTING
|
||||
iv_key = lv_key.
|
||||
ei_page = get_page_background( lv_key ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
WHEN 'abapgithome'.
|
||||
cl_gui_frontend_services=>execute( EXPORTING document = gc_abapgit_homepage
|
||||
EXCEPTIONS OTHERS = 1 ).
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'Opening page in external browser failed.' ).
|
||||
ENDIF.
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN 'abapgit_installation'.
|
||||
abapgit_installation( ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'jump'.
|
||||
lcl_html_action_utils=>jump_decode( EXPORTING iv_string = iv_getdata
|
||||
IMPORTING ev_obj_type = ls_item-obj_type
|
||||
|
@ -123,84 +87,82 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
WHEN 'diff'.
|
||||
ei_page = get_page_diff( iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
|
||||
" DB actions
|
||||
WHEN 'db_display' OR 'db_edit'.
|
||||
ei_page = get_page_db_by_name( iv_name = iv_action iv_getdata = iv_getdata ).
|
||||
IF iv_prev_page = 'PAGE_DB_DISPLAY'.
|
||||
ev_state = gc_event_state-new_page_replacing.
|
||||
ELSE.
|
||||
ev_state = gc_event_state-new_page.
|
||||
ENDIF.
|
||||
WHEN 'db_delete'.
|
||||
db_delete( iv_getdata = iv_getdata ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'db_save'.
|
||||
db_save( it_postdata ).
|
||||
ev_state = gc_event_state-go_back.
|
||||
|
||||
" Repository state actions
|
||||
WHEN 'uninstall'.
|
||||
lv_key = iv_getdata.
|
||||
repo_purge( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'remove'.
|
||||
lv_key = iv_getdata.
|
||||
repo_remove( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'zipimport'.
|
||||
lv_key = iv_getdata.
|
||||
lcl_zip=>import( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'zipexport'.
|
||||
lv_key = iv_getdata.
|
||||
lcl_zip=>export( lcl_app=>repo_srv( )->get( lv_key ) ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN 'files_commit'. "TODO refactor name ?
|
||||
lv_key = iv_getdata.
|
||||
lcl_zip=>export( io_repo = lcl_app=>repo_srv( )->get( lv_key )
|
||||
iv_zip = abap_false ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN 'packagezip'.
|
||||
lcl_popups=>repo_package_zip( ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN 'transportzip'.
|
||||
lcl_transport=>zip( ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN 'refresh'.
|
||||
lv_key = iv_getdata.
|
||||
lcl_app=>repo_srv( )->get( lv_key )->refresh( ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
" explore page
|
||||
WHEN 'install'.
|
||||
lv_url = iv_getdata.
|
||||
lcl_popups=>repo_clone( lv_url ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
" Repository online actions
|
||||
WHEN 'pull'.
|
||||
lv_key = iv_getdata.
|
||||
repo_pull( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'stage'.
|
||||
lv_key = iv_getdata.
|
||||
ei_page = get_page_stage( lv_key ).
|
||||
ev_state = gc_event_state-new_page_w_bookmark.
|
||||
WHEN 'reset'.
|
||||
lv_key = iv_getdata.
|
||||
reset( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'create_branch'.
|
||||
lv_key = iv_getdata.
|
||||
create_branch( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN 'branch_overview'.
|
||||
ei_page = get_page_branch_overview( iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
|
||||
" DB actions
|
||||
WHEN gc_action-db_display OR gc_action-db_edit.
|
||||
ei_page = get_page_db_by_name( iv_name = iv_action iv_getdata = iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
IF iv_prev_page = 'PAGE_DB_DISPLAY'.
|
||||
ev_state = gc_event_state-new_page_replacing.
|
||||
ENDIF.
|
||||
WHEN gc_action-db_delete.
|
||||
ls_db = lcl_html_action_utils=>dbkey_decode( iv_getdata ).
|
||||
lcl_services_db=>delete( ls_db ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-db_update.
|
||||
ls_db = lcl_html_action_utils=>dbcontent_decode( it_postdata ).
|
||||
lcl_services_db=>update( ls_db ).
|
||||
ev_state = gc_event_state-go_back.
|
||||
|
||||
" Abapgit services actions
|
||||
WHEN gc_action-abapgit_home.
|
||||
lcl_services_abapgit=>open_abapgit_homepage( ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN gc_action-abapgit_install.
|
||||
lcl_services_abapgit=>install_abapgit( ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
" Repository services actions
|
||||
WHEN gc_action-repo_refresh. " Repo refresh
|
||||
lcl_services_repo=>refresh( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-repo_purge. " Repo remove & purge all objects
|
||||
lcl_services_repo=>purge( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-repo_remove. " Repo remove
|
||||
lcl_services_repo=>remove( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-repo_clone OR 'install'. " Repo clone, 'install' is for explore page
|
||||
lcl_services_repo=>clone( lv_url ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
" ZIP services actions
|
||||
WHEN gc_action-zip_import. " Import repo from ZIP
|
||||
lcl_zip=>import( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-zip_export. " Export repo as ZIP
|
||||
lcl_zip=>export( lcl_app=>repo_srv( )->get( lv_key ) ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN gc_action-zip_package. " Export package as ZIP
|
||||
lcl_zip=>export_package( ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
WHEN gc_action-zip_transport. " Export transport as ZIP
|
||||
lcl_transport=>zip( ).
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
|
||||
" Git actions
|
||||
WHEN gc_action-git_pull.
|
||||
lcl_services_git=>pull( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-git_reset.
|
||||
lcl_services_git=>reset( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN gc_action-git_branch_create.
|
||||
lcl_services_git=>create_branch( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
"Others
|
||||
WHEN OTHERS.
|
||||
ev_state = gc_event_state-not_handled.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD. " on_event
|
||||
|
||||
METHOD get_page_by_name.
|
||||
|
@ -302,259 +264,6 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD abapgit_installation.
|
||||
|
||||
CONSTANTS lc_package_abapgit TYPE devclass VALUE '$ABAPGIT'.
|
||||
CONSTANTS lc_package_plugins TYPE devclass VALUE '$ABAPGIT_PLUGINS'.
|
||||
|
||||
DATA lv_text TYPE c LENGTH 100.
|
||||
DATA lv_answer TYPE c LENGTH 1.
|
||||
DATA lo_repo TYPE REF TO lcl_repo_online.
|
||||
DATA lv_url TYPE string.
|
||||
DATA lv_target_package TYPE devclass.
|
||||
|
||||
lv_text = |Installing current version ABAPGit to package { lc_package_abapgit } |
|
||||
&& |and plugins to { lc_package_plugins }|.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Install abapGit'
|
||||
text_question = lv_text
|
||||
text_button_1 = 'Continue'
|
||||
text_button_2 = 'Cancel'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer ##no_text.
|
||||
IF lv_answer <> '1'.
|
||||
RETURN. ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
ENDIF.
|
||||
|
||||
DO 2 TIMES.
|
||||
CASE sy-index.
|
||||
WHEN 1.
|
||||
lv_url = 'https://github.com/larshp/abapGit.git'.
|
||||
lv_target_package = lc_package_abapgit.
|
||||
WHEN 2.
|
||||
lv_url = 'https://github.com/larshp/abapGit-plugins.git' ##no_text.
|
||||
lv_target_package = lc_package_plugins.
|
||||
ENDCASE.
|
||||
|
||||
IF abap_false = lcl_app=>repo_srv( )->is_repo_installed(
|
||||
iv_url = lv_url
|
||||
iv_target_package = lv_target_package ).
|
||||
|
||||
lcl_sap_package=>create_local( lv_target_package ).
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->new_online(
|
||||
iv_url = lv_url
|
||||
iv_branch_name = 'refs/heads/master' "TODO replace with HEAD ?
|
||||
iv_package = lv_target_package ) ##NO_TEXT.
|
||||
|
||||
lo_repo->status( ). " check for errors
|
||||
lo_repo->deserialize( ).
|
||||
ENDIF.
|
||||
ENDDO.
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "abapgit_installation
|
||||
|
||||
METHOD repo_purge.
|
||||
|
||||
DATA: lt_tadir TYPE ty_tadir_tt,
|
||||
lv_count TYPE c LENGTH 3,
|
||||
lv_answer TYPE c LENGTH 1,
|
||||
lo_repo TYPE REF TO lcl_repo,
|
||||
lv_package TYPE devclass,
|
||||
lv_question TYPE c LENGTH 100.
|
||||
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot purge. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lv_package = lo_repo->get_package( ).
|
||||
lt_tadir = lcl_tadir=>read( lv_package ).
|
||||
|
||||
IF lines( lt_tadir ) > 0.
|
||||
lv_count = lines( lt_tadir ).
|
||||
|
||||
CONCATENATE 'This will delete all objects in package' lv_package
|
||||
INTO lv_question
|
||||
SEPARATED BY space. "#EC NOTEXT
|
||||
|
||||
CONCATENATE lv_question '(' lv_count 'objects)'
|
||||
INTO lv_question
|
||||
SEPARATED BY space. "#EC NOTEXT
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Uninstall'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Delete'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lcl_objects=>delete( lt_tadir ).
|
||||
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>repo_srv( )->delete( lo_repo ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "repo_purge
|
||||
|
||||
METHOD repo_remove.
|
||||
|
||||
DATA: lv_answer TYPE c LENGTH 1,
|
||||
lo_repo TYPE REF TO lcl_repo,
|
||||
lv_package TYPE devclass,
|
||||
lv_question TYPE c LENGTH 100.
|
||||
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->get( iv_key ).
|
||||
lv_package = lo_repo->get_package( ).
|
||||
|
||||
CONCATENATE 'This will remove the repository reference to the package'
|
||||
lv_package
|
||||
INTO lv_question
|
||||
SEPARATED BY space. "#EC NOTEXT
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Remove'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Remove'
|
||||
icon_button_1 = 'ICON_WF_UNLINK'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>repo_srv( )->delete( lo_repo ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "repo_remove
|
||||
|
||||
METHOD reset.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
lv_answer TYPE c LENGTH 1.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot reset. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Warning'
|
||||
text_question = 'Reset local objects?'
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_OKAY'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD create_branch.
|
||||
|
||||
DATA: lv_name TYPE string,
|
||||
lv_cancel TYPE abap_bool,
|
||||
lo_repo TYPE REF TO lcl_repo_online.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
lcl_popups=>create_branch_popup(
|
||||
IMPORTING
|
||||
ev_name = lv_name
|
||||
ev_cancel = lv_cancel ).
|
||||
IF lv_cancel = abap_true.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
ASSERT lv_name CP 'refs/heads/+*'.
|
||||
|
||||
lcl_git_porcelain=>create_branch(
|
||||
io_repo = lo_repo
|
||||
iv_name = lv_name
|
||||
iv_from = lo_repo->get_sha1_local( ) ).
|
||||
|
||||
* automatically switch to new branch
|
||||
lo_repo->set_branch_name( lv_name ).
|
||||
|
||||
MESSAGE 'Switched to new branch' TYPE 'S' ##NO_TEXT.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD repo_pull.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online.
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot pull. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lo_repo->refresh( ).
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "pull
|
||||
|
||||
METHOD get_page_stage.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
|
@ -574,79 +283,12 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD db_delete.
|
||||
METHOD get_page_background.
|
||||
|
||||
DATA: lv_answer TYPE c LENGTH 1,
|
||||
ls_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
|
||||
ls_key = lcl_html_action_utils=>dbkey_decode( iv_getdata ).
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
CREATE OBJECT ri_page TYPE lcl_gui_page_background
|
||||
EXPORTING
|
||||
titlebar = 'Warning'
|
||||
text_question = 'Delete?'
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
iv_key = iv_key.
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>db( )->delete(
|
||||
iv_type = ls_key-type
|
||||
iv_value = ls_key-value ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD db_save.
|
||||
|
||||
DATA: lv_string TYPE string,
|
||||
ls_content TYPE lcl_persistence_db=>ty_content,
|
||||
lt_fields TYPE tihttpnvp.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
||||
|
||||
CONCATENATE LINES OF it_postdata INTO lv_string.
|
||||
|
||||
lt_fields = cl_http_utility=>if_http_utility~string_to_fields( lv_string ).
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'type' ##NO_TEXT.
|
||||
ASSERT sy-subrc = 0.
|
||||
ls_content-type = <ls_field>-value.
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'value' ##NO_TEXT.
|
||||
ASSERT sy-subrc = 0.
|
||||
ls_content-value = <ls_field>-value.
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'xmldata' ##NO_TEXT.
|
||||
ASSERT sy-subrc = 0.
|
||||
IF <ls_field>-value(1) <> '<'.
|
||||
ls_content-data_str = <ls_field>-value+1. " hmm
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>db( )->update(
|
||||
iv_type = ls_content-type
|
||||
iv_value = ls_content-value
|
||||
iv_data = ls_content-data_str ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD.
|
||||
ENDMETHOD. "get_page_background
|
||||
|
||||
ENDCLASS. " lcl_gui_router
|
|
@ -46,6 +46,10 @@ CLASS lcl_html_action_utils DEFINITION FINAL.
|
|||
IMPORTING iv_string TYPE clike
|
||||
RETURNING VALUE(rs_key) TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
CLASS-METHODS dbcontent_decode
|
||||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
RETURNING VALUE(rs_content) TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
CLASS-METHODS parse_commit_request
|
||||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
RETURNING VALUE(rs_fields) TYPE ty_commit_fields.
|
||||
|
@ -54,6 +58,9 @@ CLASS lcl_html_action_utils DEFINITION FINAL.
|
|||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RETURNING VALUE(rv_string) TYPE string.
|
||||
|
||||
CLASS-METHODS field_keys_to_upper
|
||||
CHANGING ct_fields TYPE tihttpnvp.
|
||||
|
||||
ENDCLASS. "lcl_html_action_utils DEFINITION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -192,6 +199,7 @@ CLASS lcl_html_action_utils IMPLEMENTATION.
|
|||
|
||||
lv_string = iv_string. " type conversion
|
||||
lt_fields = cl_http_utility=>if_http_utility~string_to_fields( lv_string ).
|
||||
field_keys_to_upper( CHANGING ct_fields = lt_fields ).
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'TYPE'.
|
||||
IF sy-subrc = 0.
|
||||
|
@ -205,6 +213,26 @@ CLASS lcl_html_action_utils IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "dbkey_decode
|
||||
|
||||
METHOD dbcontent_decode.
|
||||
|
||||
DATA: lt_fields TYPE tihttpnvp,
|
||||
lv_string TYPE string.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
||||
CONCATENATE LINES OF it_postdata INTO lv_string.
|
||||
rs_content = dbkey_decode( lv_string ).
|
||||
|
||||
lt_fields = cl_http_utility=>if_http_utility~string_to_fields( lv_string ).
|
||||
field_keys_to_upper( CHANGING ct_fields = lt_fields ).
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'XMLDATA' ##NO_TEXT.
|
||||
IF sy-subrc = 0 AND <ls_field>-value(1) <> '<'.
|
||||
rs_content-data_str = <ls_field>-value+1. " hmm
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "dbcontent_decode
|
||||
|
||||
METHOD parse_commit_request.
|
||||
|
||||
CONSTANTS: lc_replace TYPE string VALUE '<<new>>'.
|
||||
|
@ -257,4 +285,14 @@ CLASS lcl_html_action_utils IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "repo_key_encode
|
||||
|
||||
METHOD field_keys_to_upper.
|
||||
|
||||
FIELD-SYMBOLS <field> LIKE LINE OF ct_fields.
|
||||
|
||||
LOOP AT ct_fields ASSIGNING <field>.
|
||||
<field>-name = to_upper( <field>-name ).
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD. "field_keys_to_upper
|
||||
|
||||
ENDCLASS. "lcl_html_action_utils IMPLEMENTATION
|
|
@ -47,19 +47,11 @@ CLASS lcl_objects IMPLEMENTATION.
|
|||
} { <ls_result>-obj_name
|
||||
} has been modified locally, overwrite object?|.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Warning'
|
||||
text_question = lv_question
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2 ##NO_TEXT.
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Warning'
|
||||
text_question = lv_question
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
DELETE ct_results INDEX lv_index.
|
||||
|
@ -85,24 +77,16 @@ CLASS lcl_objects IMPLEMENTATION.
|
|||
'from package' ls_tadir-devclass
|
||||
INTO lv_question SEPARATED BY space. "#EC NOTEXT
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Warning'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Warning'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
rv_cancel = abap_true.
|
||||
|
|
|
@ -14,7 +14,7 @@ INTERFACE lif_gui_page.
|
|||
it_postdata TYPE cnht_post_data_tab OPTIONAL
|
||||
EXPORTING ei_page TYPE REF TO lif_gui_page
|
||||
ev_state TYPE i
|
||||
RAISING lcx_exception.
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
METHODS render
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
|
@ -141,7 +141,7 @@ CLASS lcl_gui_page_super IMPLEMENTATION.
|
|||
ro_html->add( |<span class="{ lv_class }">| ).
|
||||
ro_html->add( '<img src="img/branch">' ).
|
||||
IF iv_interactive = abap_true.
|
||||
ro_html->add_anchor( iv_act = |switch_branch?{ io_repo->get_key( ) }|
|
||||
ro_html->add_anchor( iv_act = |{ gc_action-git_branch_switch }?{ io_repo->get_key( ) }|
|
||||
iv_txt = lv_text ).
|
||||
ELSE.
|
||||
ro_html->add( lv_text ).
|
||||
|
@ -180,7 +180,7 @@ CLASS lcl_gui_page_super IMPLEMENTATION.
|
|||
ro_html->add( '<table width="100%"><tr>' ). "#EC NOTEXT
|
||||
|
||||
ro_html->add( '<td class="logo">' ). "#EC NOTEXT
|
||||
ro_html->add( '<a href="sapevent:abapgithome">' ). "#EC NOTEXT
|
||||
ro_html->add( |<a href="sapevent:{ gc_action-abapgit_home }">| ). "#EC NOTEXT
|
||||
ro_html->add( '<img src="img/logo">' ). "#EC NOTEXT
|
||||
ro_html->add( '</a>' ). "#EC NOTEXT
|
||||
ro_html->add( '</td>' ). "#EC NOTEXT
|
||||
|
|
|
@ -59,7 +59,7 @@ CLASS lcl_gui_page_db_display IMPLEMENTATION.
|
|||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
|
||||
ro_html->add( '</td><td class="right">' ).
|
||||
ro_html->add_anchor( iv_txt = 'Edit' iv_act = |db_edit?{ lv_action }| ).
|
||||
ro_html->add_anchor( iv_txt = 'Edit' iv_act = |{ gc_action-db_edit }?{ lv_action }| ).
|
||||
ro_html->add( '</td></tr></table>' ).
|
||||
|
||||
ro_html->add( |<pre>{ lv_data }</pre>| ).
|
||||
|
@ -170,7 +170,7 @@ CLASS lcl_gui_page_db_edit IMPLEMENTATION.
|
|||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
|
||||
" Form
|
||||
ro_html->add( '<form id="db_form" method="post" action="sapevent:db_save">' ).
|
||||
ro_html->add( |<form id="db_form" method="post" action="sapevent:{ gc_action-db_update }">| ).
|
||||
ro_html->add( |<input type="hidden" name="type" value="{ ms_key-type }">| ).
|
||||
ro_html->add( |<input type="hidden" name="value" value="{ ms_key-value }">| ).
|
||||
ro_html->add( |<textarea rows="20" cols="100" name="xmldata">{ lv_data
|
||||
|
@ -283,9 +283,9 @@ CLASS lcl_gui_page_db IMPLEMENTATION.
|
|||
lv_action = lcl_html_action_utils=>dbkey_encode( <ls_data> ).
|
||||
|
||||
CREATE OBJECT lo_toolbar.
|
||||
lo_toolbar->add( iv_txt = 'Display' iv_act = |db_display?{ lv_action }| ).
|
||||
lo_toolbar->add( iv_txt = 'Edit' iv_act = |db_edit?{ lv_action }| ).
|
||||
lo_toolbar->add( iv_txt = 'Delete' iv_act = |db_delete?{ lv_action }| ).
|
||||
lo_toolbar->add( iv_txt = 'Display' iv_act = |{ gc_action-db_display }?{ lv_action }| ).
|
||||
lo_toolbar->add( iv_txt = 'Edit' iv_act = |{ gc_action-db_edit }?{ lv_action }| ).
|
||||
lo_toolbar->add( iv_txt = 'Delete' iv_act = |{ gc_action-db_delete }?{ lv_action }| ).
|
||||
|
||||
ro_html->add( |<tr{ lv_trclass }>| ).
|
||||
ro_html->add( |<td>{ <ls_data>-type }</td>| ).
|
||||
|
|
|
@ -14,10 +14,6 @@ CLASS lcl_gui_page_main DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
|||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS: BEGIN OF c_actions,
|
||||
newoffline TYPE string VALUE 'newoffline' ##NO_TEXT,
|
||||
switch_branch TYPE string VALUE 'switch_branch' ##NO_TEXT,
|
||||
delete_branch TYPE string VALUE 'delete_branch' ##NO_TEXT,
|
||||
install TYPE string VALUE 'install' ##NO_TEXT,
|
||||
show TYPE string VALUE 'show' ##NO_TEXT,
|
||||
END OF c_actions.
|
||||
|
||||
|
@ -35,7 +31,7 @@ CLASS lcl_gui_page_main DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
|||
DATA: mv_show TYPE lcl_persistence_db=>ty_value.
|
||||
|
||||
METHODS:
|
||||
check_show
|
||||
retrieve_active_repo
|
||||
RAISING lcx_exception,
|
||||
styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
|
@ -77,9 +73,7 @@ CLASS lcl_gui_page_main DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
|||
RETURNING VALUE(rv_html) TYPE string,
|
||||
render_explore
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception,
|
||||
needs_installation
|
||||
RETURNING VALUE(rv_not_completely_installed) TYPE abap_bool.
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -89,42 +83,38 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
|
||||
super->constructor( ).
|
||||
|
||||
mv_show = lcl_app=>user( )->get_repo_show( ).
|
||||
|
||||
check_show( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_show.
|
||||
METHOD retrieve_active_repo.
|
||||
|
||||
DATA: lt_repos TYPE lcl_repo_srv=>ty_repo_tt,
|
||||
lo_repo LIKE LINE OF lt_repos.
|
||||
|
||||
|
||||
TRY.
|
||||
lt_repos = lcl_app=>repo_srv( )->list( ).
|
||||
CATCH lcx_exception.
|
||||
RETURN.
|
||||
ENDTRY.
|
||||
|
||||
IF mv_show IS INITIAL.
|
||||
READ TABLE lt_repos INTO lo_repo INDEX 1.
|
||||
IF sy-subrc = 0.
|
||||
mv_show = lo_repo->get_key( ).
|
||||
ENDIF.
|
||||
ELSE.
|
||||
TRY.
|
||||
* verify the key exists
|
||||
mv_show = lcl_app=>user( )->get_repo_show( ). " Get default repo from user cfg
|
||||
|
||||
IF mv_show IS NOT INITIAL.
|
||||
TRY. " verify the key exists
|
||||
lo_repo = lcl_app=>repo_srv( )->get( mv_show ).
|
||||
CATCH lcx_exception.
|
||||
READ TABLE lt_repos INTO lo_repo INDEX 1.
|
||||
IF sy-subrc = 0.
|
||||
mv_show = lo_repo->get_key( ).
|
||||
ENDIF.
|
||||
clear mv_show.
|
||||
ENDTRY.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
IF mv_show IS INITIAL. " Fall back to first available repo
|
||||
READ TABLE lt_repos INTO lo_repo INDEX 1.
|
||||
IF sy-subrc = 0.
|
||||
mv_show = lo_repo->get_key( ).
|
||||
lcl_app=>user( )->set_repo_show( mv_show ).
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "retrieve_active_repo
|
||||
|
||||
METHOD render_obj_jump_link.
|
||||
|
||||
|
@ -149,14 +139,14 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
CREATE OBJECT lo_betasub.
|
||||
|
||||
lo_betasub->add( iv_txt = 'Database util' iv_act = 'db' ) ##NO_TEXT.
|
||||
lo_betasub->add( iv_txt = 'Package to zip' iv_act = 'packagezip' ) ##NO_TEXT.
|
||||
lo_betasub->add( iv_txt = 'Transport to zip' iv_act = 'transportzip' ) ##NO_TEXT.
|
||||
lo_betasub->add( iv_txt = 'Package to zip' iv_act = gc_action-zip_package ) ##NO_TEXT.
|
||||
lo_betasub->add( iv_txt = 'Transport to zip' iv_act = gc_action-zip_transport ) ##NO_TEXT.
|
||||
|
||||
ro_menu->add( iv_txt = 'Clone' iv_act = c_actions-install ) ##NO_TEXT.
|
||||
ro_menu->add( iv_txt = 'Clone' iv_act = gc_action-repo_clone ) ##NO_TEXT.
|
||||
ro_menu->add( iv_txt = 'Explore' iv_act = 'explore' ) ##NO_TEXT.
|
||||
ro_menu->add( iv_txt = 'New offline repo' iv_act = c_actions-newoffline ) ##NO_TEXT.
|
||||
IF needs_installation( ) = abap_true.
|
||||
ro_menu->add( iv_txt = 'Get abapGit' iv_act = 'abapgit_installation' ) ##NO_TEXT.
|
||||
ro_menu->add( iv_txt = 'New offline repo' iv_act = gc_action-repo_newoffline ) ##NO_TEXT.
|
||||
IF lcl_services_abapgit=>needs_installation( ) = abap_true.
|
||||
ro_menu->add( iv_txt = 'Get abapGit' iv_act = gc_action-abapgit_install ) ##NO_TEXT.
|
||||
ENDIF.
|
||||
ro_menu->add( iv_txt = 'Advanced' io_sub = lo_betasub ) ##NO_TEXT.
|
||||
|
||||
|
@ -210,19 +200,20 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
METHOD render_repo_menu.
|
||||
|
||||
DATA: lo_toolbar TYPE REF TO lcl_html_toolbar,
|
||||
lo_tb_advanced TYPE REF TO lcl_html_toolbar,
|
||||
lo_tb_branch TYPE REF TO lcl_html_toolbar,
|
||||
lv_key TYPE lcl_persistence_db=>ty_value,
|
||||
lv_wp_opt LIKE gc_html_opt-crossout,
|
||||
lv_pull_opt LIKE gc_html_opt-crossout,
|
||||
lo_sub TYPE REF TO lcl_html_toolbar,
|
||||
lo_branch TYPE REF TO lcl_html_toolbar,
|
||||
lo_repo_online TYPE REF TO lcl_repo_online.
|
||||
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
CREATE OBJECT lo_tb_branch.
|
||||
CREATE OBJECT lo_tb_advanced.
|
||||
|
||||
lv_key = io_repo->get_key( ).
|
||||
|
||||
IF io_repo->is_offline( ) = abap_false.
|
||||
lo_repo_online ?= io_repo.
|
||||
ENDIF.
|
||||
|
@ -234,18 +225,39 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
lv_pull_opt = gc_html_opt-emphas.
|
||||
ENDIF.
|
||||
|
||||
IF io_repo->is_offline( ) = abap_true.
|
||||
lo_toolbar->add( iv_txt = 'Import ZIP'
|
||||
iv_act = |zipimport?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
lo_toolbar->add( iv_txt = 'Export ZIP'
|
||||
iv_act = |zipexport?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
ELSE.
|
||||
" Build branch drop-down ========================
|
||||
IF io_repo->is_offline( ) = abap_false. " Online ?
|
||||
lo_tb_branch->add( iv_txt = 'Overview'
|
||||
iv_act = |branch_overview?{ lv_key }| ).
|
||||
lo_tb_branch->add( iv_txt = 'Switch'
|
||||
iv_act = |{ gc_action-git_branch_switch }?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_tb_branch->add( iv_txt = 'Create'
|
||||
iv_act = |{ gc_action-git_branch_create }?{ lv_key }| ).
|
||||
lo_tb_branch->add( iv_txt = 'Delete'
|
||||
iv_act = |{ gc_action-git_branch_delete }?{ lv_key }| ).
|
||||
ENDIF.
|
||||
|
||||
" Build advanced drop-down ========================
|
||||
IF io_repo->is_offline( ) = abap_false. " Online ?
|
||||
lo_tb_advanced->add( iv_txt = 'Reset local'
|
||||
iv_act = |{ gc_action-git_reset }?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_tb_advanced->add( iv_txt = 'Background mode'
|
||||
iv_act = |background?{ lv_key }| ).
|
||||
ENDIF.
|
||||
lo_tb_advanced->add( iv_txt = 'Remove'
|
||||
iv_act = |{ gc_action-repo_remove }?{ lv_key }| ).
|
||||
lo_tb_advanced->add( iv_txt = 'Uninstall'
|
||||
iv_act = |{ gc_action-repo_purge }?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
|
||||
" Build main toolbar ==============================
|
||||
IF io_repo->is_offline( ) = abap_false. " Online ?
|
||||
TRY.
|
||||
IF lo_repo_online->get_sha1_remote( ) <> lo_repo_online->get_sha1_local( ).
|
||||
lo_toolbar->add( iv_txt = 'Pull'
|
||||
iv_act = |pull?{ lv_key }|
|
||||
iv_act = |{ gc_action-git_pull }?{ lv_key }|
|
||||
iv_opt = lv_pull_opt ).
|
||||
ELSEIF lcl_stage_logic=>count( lo_repo_online ) > 0.
|
||||
lo_toolbar->add( iv_txt = 'Stage'
|
||||
|
@ -253,47 +265,26 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
iv_opt = gc_html_opt-emphas ).
|
||||
ENDIF.
|
||||
CATCH lcx_exception ##NO_HANDLER.
|
||||
* authorization error or repository does not exist
|
||||
* ignore error
|
||||
" authorization error or repository does not exist
|
||||
" ignore error
|
||||
ENDTRY.
|
||||
ENDIF.
|
||||
|
||||
CREATE OBJECT lo_sub.
|
||||
IF io_repo->is_offline( ) = abap_false.
|
||||
CREATE OBJECT lo_branch.
|
||||
lo_branch->add( iv_txt = 'Overview'
|
||||
iv_act = |branch_overview?{ lv_key }| ).
|
||||
lo_branch->add( iv_txt = 'Switch'
|
||||
iv_act = |{ c_actions-switch_branch }?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_branch->add( iv_txt = 'Create'
|
||||
iv_act = |create_branch?{ lv_key }| ).
|
||||
lo_branch->add( iv_txt = 'Delete'
|
||||
iv_act = |{ c_actions-delete_branch }?{ lv_key }| ).
|
||||
lo_toolbar->add( iv_txt = 'Branch'
|
||||
io_sub = lo_branch ) ##NO_TEXT.
|
||||
|
||||
lo_sub->add( iv_txt = 'Reset local'
|
||||
iv_act = |reset?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_sub->add( iv_txt = 'Background mode'
|
||||
iv_act = |background?{ lv_key }| ).
|
||||
io_sub = lo_tb_branch ) ##NO_TEXT.
|
||||
ELSE.
|
||||
lo_sub->add( iv_txt = 'Export & Commit'
|
||||
iv_act = |files_commit?{ lv_key }| ).
|
||||
lo_toolbar->add( iv_txt = 'Import ZIP'
|
||||
iv_act = |{ gc_action-zip_import }?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
lo_toolbar->add( iv_txt = 'Export ZIP'
|
||||
iv_act = |{ gc_action-zip_export }?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
ENDIF.
|
||||
lo_sub->add( iv_txt = 'Remove'
|
||||
iv_act = |remove?{ lv_key }| ).
|
||||
lo_sub->add( iv_txt = 'Uninstall'
|
||||
iv_act = |uninstall?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
|
||||
lo_toolbar->add( iv_txt = 'Advanced'
|
||||
io_sub = lo_sub ) ##NO_TEXT.
|
||||
|
||||
io_sub = lo_tb_advanced ) ##NO_TEXT.
|
||||
lo_toolbar->add( iv_txt = 'Refresh'
|
||||
iv_act = |refresh?{ lv_key }| ).
|
||||
iv_act = |{ gc_action-repo_refresh }?{ lv_key }| ).
|
||||
|
||||
" Render ==========================================
|
||||
ro_html->add( '<div class="paddings right">' ).
|
||||
ro_html->add( lo_toolbar->render( ) ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
@ -501,23 +492,6 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD needs_installation.
|
||||
|
||||
CONSTANTS:
|
||||
lc_abapgit TYPE string VALUE 'https://github.com/larshp/abapGit.git',
|
||||
lc_plugins TYPE string VALUE 'https://github.com/larshp/abapGit-plugins.git' ##NO_TEXT.
|
||||
|
||||
TRY.
|
||||
IF lcl_app=>repo_srv( )->is_repo_installed( lc_abapgit ) = abap_false
|
||||
OR lcl_app=>repo_srv( )->is_repo_installed( lc_plugins ) = abap_false.
|
||||
rv_not_completely_installed = abap_true.
|
||||
ENDIF.
|
||||
CATCH lcx_exception.
|
||||
" cannot be installed anyway in this case, e.g. no connection
|
||||
rv_not_completely_installed = abap_false.
|
||||
ENDTRY.
|
||||
ENDMETHOD. "needs_installation
|
||||
|
||||
METHOD render_toc.
|
||||
|
||||
DATA: lo_pback TYPE REF TO lcl_persistence_background,
|
||||
|
@ -634,39 +608,22 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
METHOD lif_gui_page~on_event.
|
||||
|
||||
DATA: lv_key TYPE lcl_persistence_repo=>ty_repo-key,
|
||||
lo_repo TYPE REF TO lcl_repo,
|
||||
lv_url TYPE string.
|
||||
|
||||
lv_key = iv_getdata.
|
||||
|
||||
CASE iv_action.
|
||||
WHEN c_actions-newoffline.
|
||||
ev_state = gc_event_state-no_more_act.
|
||||
lo_repo = lcl_popups=>repo_new_offline( ).
|
||||
IF lo_repo IS BOUND.
|
||||
mv_show = lo_repo->get_key( ).
|
||||
lcl_app=>user( )->set_repo_show( mv_show ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
ENDIF.
|
||||
WHEN c_actions-delete_branch.
|
||||
lv_key = iv_getdata.
|
||||
lcl_popups=>delete_branch( lv_key ).
|
||||
WHEN gc_action-repo_newoffline. " New offline repo
|
||||
lcl_services_repo=>new_offline( ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN c_actions-switch_branch.
|
||||
lv_key = iv_getdata.
|
||||
lcl_popups=>switch_branch( lv_key ).
|
||||
WHEN gc_action-git_branch_delete. " Delete remote branch
|
||||
lcl_services_git=>delete_branch( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN c_actions-install.
|
||||
lv_url = iv_getdata.
|
||||
lo_repo = lcl_popups=>repo_clone( lv_url ).
|
||||
IF lo_repo IS BOUND.
|
||||
* cancel not pressed
|
||||
mv_show = lo_repo->get_key( ).
|
||||
lcl_app=>user( )->set_repo_show( mv_show ).
|
||||
ENDIF.
|
||||
WHEN gc_action-git_branch_switch. " Switch branch
|
||||
lcl_services_git=>switch_branch( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
WHEN c_actions-show.
|
||||
mv_show = iv_getdata.
|
||||
lcl_app=>user( )->set_repo_show( mv_show ).
|
||||
WHEN c_actions-show. " Change displayed repo
|
||||
lcl_app=>user( )->set_repo_show( lv_key ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
ENDCASE.
|
||||
|
||||
|
@ -678,6 +635,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
lx_error TYPE REF TO lcx_exception,
|
||||
lo_repo LIKE LINE OF lt_repos.
|
||||
|
||||
retrieve_active_repo( ). " Get and validate key of user default repo
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
|
@ -696,7 +654,6 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
IF lines( lt_repos ) = 0 AND lx_error IS INITIAL.
|
||||
ro_html->add( render_explore( ) ).
|
||||
ELSE.
|
||||
check_show( ).
|
||||
lo_repo = lcl_app=>repo_srv( )->get( mv_show ).
|
||||
ro_html->add( render_repo( lo_repo ) ).
|
||||
ENDIF.
|
||||
|
|
|
@ -13,25 +13,24 @@ CLASS lcl_popups DEFINITION.
|
|||
cancel TYPE abap_bool,
|
||||
END OF ty_popup.
|
||||
|
||||
CONSTANTS c_new_branch_label TYPE string VALUE 'Create NEW ...'.
|
||||
|
||||
CLASS-METHODS:
|
||||
repo_package_zip
|
||||
popup_package_export
|
||||
RETURNING VALUE(rv_package) TYPE devclass
|
||||
RAISING lcx_exception,
|
||||
create_branch_popup
|
||||
EXPORTING ev_name TYPE string
|
||||
ev_cancel TYPE abap_bool
|
||||
RAISING lcx_exception,
|
||||
repo_new_offline
|
||||
RETURNING VALUE(ro_repo) TYPE REF TO lcl_repo_offline
|
||||
RAISING lcx_exception,
|
||||
switch_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception,
|
||||
delete_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RETURNING VALUE(rs_popup) TYPE ty_popup
|
||||
RAISING lcx_exception,
|
||||
branch_list_popup
|
||||
IMPORTING iv_url TYPE string
|
||||
RETURNING VALUE(rs_branch) TYPE lcl_git_branch_list=>ty_git_branch
|
||||
IMPORTING iv_url TYPE string
|
||||
iv_default_branch TYPE string OPTIONAL
|
||||
iv_show_new_option TYPE abap_bool OPTIONAL
|
||||
RETURNING VALUE(rs_branch) TYPE lcl_git_branch_list=>ty_git_branch
|
||||
RAISING lcx_exception,
|
||||
repo_popup
|
||||
IMPORTING iv_url TYPE string
|
||||
|
@ -39,9 +38,17 @@ CLASS lcl_popups DEFINITION.
|
|||
iv_branch TYPE string DEFAULT 'refs/heads/master'
|
||||
RETURNING VALUE(rs_popup) TYPE ty_popup
|
||||
RAISING lcx_exception ##NO_TEXT,
|
||||
repo_clone
|
||||
IMPORTING iv_url TYPE string
|
||||
RETURNING VALUE(ro_repo) TYPE REF TO lcl_repo_online
|
||||
popup_to_confirm
|
||||
IMPORTING
|
||||
titlebar TYPE clike
|
||||
text_question TYPE clike
|
||||
text_button_1 TYPE clike DEFAULT 'Yes'
|
||||
icon_button_1 TYPE ICON-NAME DEFAULT space
|
||||
text_button_2 TYPE clike DEFAULT 'No'
|
||||
icon_button_2 TYPE ICON-NAME DEFAULT space
|
||||
default_button TYPE char1 DEFAULT '1'
|
||||
display_cancel_button TYPE char1 DEFAULT abap_true
|
||||
RETURNING VALUE(rv_answer) TYPE char1
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
@ -58,11 +65,9 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
END-OF-DEFINITION.
|
||||
|
||||
|
||||
METHOD repo_package_zip.
|
||||
METHOD popup_package_export.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_offline,
|
||||
ls_data TYPE lcl_persistence_repo=>ty_repo,
|
||||
lv_returncode TYPE c,
|
||||
DATA: lv_returncode TYPE c,
|
||||
lt_fields TYPE TABLE OF sval.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
@ -73,7 +78,7 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
CALL FUNCTION 'POPUP_GET_VALUES'
|
||||
EXPORTING
|
||||
no_value_check = abap_true
|
||||
popup_title = 'Export' "#EC NOTEXT
|
||||
popup_title = 'Export package' "#EC NOTEXT
|
||||
IMPORTING
|
||||
returncode = lv_returncode
|
||||
TABLES
|
||||
|
@ -84,6 +89,7 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'Error from POPUP_GET_VALUES' ).
|
||||
ENDIF.
|
||||
|
||||
IF lv_returncode = 'A'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
@ -92,17 +98,9 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
ASSERT sy-subrc = 0.
|
||||
TRANSLATE <ls_field>-value TO UPPER CASE.
|
||||
|
||||
ls_data-key = 'DUMMY'.
|
||||
ls_data-package = <ls_field>-value.
|
||||
ls_data-master_language = sy-langu.
|
||||
rv_package = <ls_field>-value.
|
||||
|
||||
CREATE OBJECT lo_repo
|
||||
EXPORTING
|
||||
is_data = ls_data.
|
||||
|
||||
lcl_zip=>export( lo_repo ).
|
||||
|
||||
ENDMETHOD. "repo_package_zip
|
||||
ENDMETHOD. "popup_package_export
|
||||
|
||||
METHOD create_branch_popup.
|
||||
|
||||
|
@ -112,8 +110,7 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
||||
|
||||
CLEAR ev_name.
|
||||
CLEAR ev_cancel.
|
||||
CLEAR: ev_name, ev_cancel.
|
||||
|
||||
* TAB FLD LABEL DEF ATTR
|
||||
_add_dialog_fld 'TEXTL' 'LINE' 'Name' 'new_branch_name' ''.
|
||||
|
@ -145,8 +142,6 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
METHOD repo_new_offline.
|
||||
|
||||
DATA: lv_returncode TYPE c,
|
||||
lv_url TYPE string,
|
||||
lv_package TYPE devclass,
|
||||
lt_fields TYPE TABLE OF sval.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
@ -170,59 +165,29 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'Error from POPUP_GET_VALUES' ).
|
||||
ENDIF.
|
||||
|
||||
IF lv_returncode = 'A'.
|
||||
rs_popup-cancel = abap_true.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_fields INDEX 1 ASSIGNING <ls_field>.
|
||||
ASSERT sy-subrc = 0.
|
||||
lv_url = <ls_field>-value.
|
||||
rs_popup-url = <ls_field>-value.
|
||||
|
||||
READ TABLE lt_fields INDEX 2 ASSIGNING <ls_field>.
|
||||
ASSERT sy-subrc = 0.
|
||||
lv_package = <ls_field>-value.
|
||||
TRANSLATE lv_package TO UPPER CASE.
|
||||
|
||||
ro_repo = lcl_app=>repo_srv( )->new_offline(
|
||||
iv_url = lv_url
|
||||
iv_package = lv_package ).
|
||||
|
||||
COMMIT WORK.
|
||||
rs_popup-package = <ls_field>-value.
|
||||
TRANSLATE rs_popup-package TO UPPER CASE.
|
||||
|
||||
ENDMETHOD. "repo_new_offline
|
||||
|
||||
METHOD delete_branch.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_branch TYPE lcl_git_branch_list=>ty_git_branch.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
ls_branch = branch_list_popup( lo_repo->get_url( ) ).
|
||||
IF ls_branch IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
IF ls_branch-name = 'HEAD'.
|
||||
lcx_exception=>raise( 'cannot delete HEAD' ).
|
||||
ELSEIF ls_branch-name = lo_repo->get_branch_name( ).
|
||||
lcx_exception=>raise( 'switch branch before deleting current' ).
|
||||
ENDIF.
|
||||
|
||||
lcl_git_porcelain=>delete_branch(
|
||||
io_repo = lo_repo
|
||||
is_branch = ls_branch ).
|
||||
|
||||
MESSAGE 'Branch deleted' TYPE 'S'.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD branch_list_popup.
|
||||
|
||||
DATA: lo_branches TYPE REF TO lcl_git_branch_list,
|
||||
lt_branches TYPE lcl_git_branch_list=>ty_git_branch_list_tt,
|
||||
lv_answer TYPE c LENGTH 1,
|
||||
lv_default TYPE i VALUE 1, "Default cursor position
|
||||
lt_selection TYPE TABLE OF spopli.
|
||||
|
||||
FIELD-SYMBOLS: <ls_sel> LIKE LINE OF lt_selection,
|
||||
|
@ -235,20 +200,24 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
LOOP AT lt_branches ASSIGNING <ls_branch>.
|
||||
APPEND INITIAL LINE TO lt_selection ASSIGNING <ls_sel>.
|
||||
<ls_sel>-varoption = <ls_branch>-name.
|
||||
|
||||
IF iv_default_branch IS NOT INITIAL AND iv_default_branch = <ls_branch>-name.
|
||||
lv_default = sy-tabix.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
* lt_branches = lo_branches->get_tags_only( ).
|
||||
* LOOP AT lt_branches ASSIGNING <ls_branch>.
|
||||
* APPEND INITIAL LINE TO lt_selection ASSIGNING <ls_sel>.
|
||||
* <ls_sel>-varoption = <ls_branch>-name.
|
||||
* ENDLOOP.
|
||||
IF iv_show_new_option = abap_true.
|
||||
APPEND INITIAL LINE TO lt_selection ASSIGNING <ls_sel>.
|
||||
<ls_sel>-varoption = c_new_branch_label.
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
|
||||
EXPORTING
|
||||
textline1 = 'Select branch'
|
||||
titel = 'Select branch'
|
||||
start_col = 5
|
||||
start_row = 10
|
||||
start_col = 30
|
||||
start_row = 5
|
||||
cursorline = lv_default
|
||||
IMPORTING
|
||||
answer = lv_answer
|
||||
TABLES
|
||||
|
@ -269,32 +238,12 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
READ TABLE lt_selection ASSIGNING <ls_sel> WITH KEY selflag = abap_true.
|
||||
ASSERT sy-subrc = 0.
|
||||
|
||||
rs_branch = lo_branches->find_by_name( <ls_sel>-varoption ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD switch_branch.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_popup TYPE ty_popup.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
ls_popup = repo_popup(
|
||||
iv_url = lo_repo->get_url( )
|
||||
iv_package = lo_repo->get_package( )
|
||||
iv_branch = lo_repo->get_branch_name( ) ).
|
||||
IF ls_popup-cancel = abap_true.
|
||||
RETURN.
|
||||
IF iv_show_new_option = abap_true AND <ls_sel>-varoption = c_new_branch_label.
|
||||
rs_branch-name = c_new_branch_label.
|
||||
ELSE.
|
||||
rs_branch = lo_branches->find_by_name( <ls_sel>-varoption ).
|
||||
ENDIF.
|
||||
|
||||
lo_repo->set_url( ls_popup-url ).
|
||||
lo_repo->set_branch_name( ls_popup-branch_name ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
@ -371,25 +320,27 @@ CLASS lcl_popups IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD repo_clone.
|
||||
METHOD popup_to_confirm.
|
||||
|
||||
DATA: ls_popup TYPE ty_popup.
|
||||
|
||||
|
||||
ls_popup = repo_popup( iv_url ).
|
||||
IF ls_popup-cancel = abap_true.
|
||||
RETURN.
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = titlebar
|
||||
text_question = text_question
|
||||
text_button_1 = text_button_1
|
||||
icon_button_1 = icon_button_1
|
||||
text_button_2 = text_button_2
|
||||
icon_button_2 = icon_button_2
|
||||
default_button = default_button
|
||||
display_cancel_button = display_cancel_button
|
||||
IMPORTING
|
||||
answer = rv_answer
|
||||
EXCEPTIONS
|
||||
text_not_found = 1
|
||||
OTHERS = 2. "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from POPUP_TO_CONFIRM' ).
|
||||
ENDIF.
|
||||
|
||||
ro_repo = lcl_app=>repo_srv( )->new_online(
|
||||
iv_url = ls_popup-url
|
||||
iv_branch_name = ls_popup-branch_name
|
||||
iv_package = ls_popup-package ).
|
||||
ro_repo->status( ). " check for errors
|
||||
ro_repo->deserialize( ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "repo_clone
|
||||
ENDMETHOD. "popup_to_confirm
|
||||
|
||||
ENDCLASS.
|
8
src/zabapgit_services.prog.abap
Normal file
8
src/zabapgit_services.prog.abap
Normal file
|
@ -0,0 +1,8 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_SERVICES
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
INCLUDE zabapgit_services_repo.
|
||||
INCLUDE zabapgit_services_abapgit.
|
||||
INCLUDE zabapgit_services_git.
|
||||
INCLUDE zabapgit_services_db.
|
48
src/zabapgit_services.prog.xml
Normal file
48
src/zabapgit_services.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_SERVICES</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
<VARCL>X</VARCL>
|
||||
<DBAPL/>
|
||||
<DBNA/>
|
||||
<CLAS/>
|
||||
<TYPE/>
|
||||
<OCCURS/>
|
||||
<SUBC>I</SUBC>
|
||||
<APPL/>
|
||||
<SECU/>
|
||||
<CNAM/>
|
||||
<CDAT>0000-00-00</CDAT>
|
||||
<UNAM/>
|
||||
<UDAT>0000-00-00</UDAT>
|
||||
<VERN/>
|
||||
<LEVL/>
|
||||
<RSTAT/>
|
||||
<RMAND/>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT/>
|
||||
<SSET/>
|
||||
<SDATE>0000-00-00</SDATE>
|
||||
<STIME/>
|
||||
<IDATE>0000-00-00</IDATE>
|
||||
<ITIME/>
|
||||
<LDBNAME/>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_SERVICES</ENTRY>
|
||||
<LENGTH>25</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
106
src/zabapgit_services_abapgit.prog.abap
Normal file
106
src/zabapgit_services_abapgit.prog.abap
Normal file
|
@ -0,0 +1,106 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_SERVICES_ABAPGIT
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_services_abapgit DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
|
||||
CONSTANTS c_abapgit_homepage TYPE string VALUE 'http://www.abapgit.org' ##NO_TEXT.
|
||||
CONSTANTS c_package_abapgit TYPE devclass VALUE '$ABAPGIT'.
|
||||
CONSTANTS c_package_plugins TYPE devclass VALUE '$ABAPGIT_PLUGINS'.
|
||||
CONSTANTS c_abapgit_url TYPE string VALUE 'https://github.com/larshp/abapGit.git'.
|
||||
CONSTANTS c_plugins_url TYPE string VALUE 'https://github.com/larshp/abapGit-plugins.git'.
|
||||
|
||||
CLASS-METHODS open_abapgit_homepage
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS install_abapgit
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS needs_installation
|
||||
RETURNING VALUE(rv_not_completely_installed) TYPE abap_bool.
|
||||
|
||||
ENDCLASS. "lcl_services_abapgit
|
||||
|
||||
CLASS lcl_services_abapgit IMPLEMENTATION.
|
||||
|
||||
METHOD open_abapgit_homepage.
|
||||
|
||||
cl_gui_frontend_services=>execute(
|
||||
EXPORTING document = c_abapgit_homepage
|
||||
EXCEPTIONS OTHERS = 1 ).
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'Opening page in external browser failed.' ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "open_abapgit_homepage
|
||||
|
||||
METHOD install_abapgit.
|
||||
|
||||
DATA lv_text TYPE c LENGTH 100.
|
||||
DATA lv_answer TYPE c LENGTH 1.
|
||||
DATA lo_repo TYPE REF TO lcl_repo_online.
|
||||
DATA lv_url TYPE string.
|
||||
DATA lv_target_package TYPE devclass.
|
||||
|
||||
lv_text = |Installing current version ABAPGit to package { c_package_abapgit } |
|
||||
&& |and plugins to { c_package_plugins }|.
|
||||
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Install abapGit'
|
||||
text_question = lv_text
|
||||
text_button_1 = 'Continue'
|
||||
text_button_2 = 'Cancel'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer <> '1'.
|
||||
RETURN. ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
ENDIF.
|
||||
|
||||
DO 2 TIMES.
|
||||
CASE sy-index.
|
||||
WHEN 1.
|
||||
lv_url = c_abapgit_url.
|
||||
lv_target_package = c_package_abapgit.
|
||||
WHEN 2.
|
||||
lv_url = c_plugins_url.
|
||||
lv_target_package = c_package_plugins.
|
||||
ENDCASE.
|
||||
|
||||
IF abap_false = lcl_app=>repo_srv( )->is_repo_installed(
|
||||
iv_url = lv_url
|
||||
iv_target_package = lv_target_package ).
|
||||
|
||||
lcl_sap_package=>create_local( lv_target_package ).
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->new_online(
|
||||
iv_url = lv_url
|
||||
iv_branch_name = 'refs/heads/master' "TODO replace with HEAD ?
|
||||
iv_package = lv_target_package ) ##NO_TEXT.
|
||||
|
||||
lo_repo->status( ). " check for errors
|
||||
lo_repo->deserialize( ).
|
||||
ENDIF.
|
||||
ENDDO.
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "install_abapgit
|
||||
|
||||
METHOD needs_installation.
|
||||
|
||||
TRY.
|
||||
IF lcl_app=>repo_srv( )->is_repo_installed( c_abapgit_url ) = abap_false
|
||||
OR lcl_app=>repo_srv( )->is_repo_installed( c_plugins_url ) = abap_false.
|
||||
rv_not_completely_installed = abap_true.
|
||||
ENDIF.
|
||||
CATCH lcx_exception.
|
||||
" cannot be installed anyway in this case, e.g. no connection
|
||||
rv_not_completely_installed = abap_false.
|
||||
ENDTRY.
|
||||
|
||||
ENDMETHOD. "needs_installation
|
||||
|
||||
ENDCLASS. "lcl_services_abapgit
|
48
src/zabapgit_services_abapgit.prog.xml
Normal file
48
src/zabapgit_services_abapgit.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_SERVICES_ABAPGIT</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
<VARCL>X</VARCL>
|
||||
<DBAPL/>
|
||||
<DBNA/>
|
||||
<CLAS/>
|
||||
<TYPE/>
|
||||
<OCCURS/>
|
||||
<SUBC>I</SUBC>
|
||||
<APPL/>
|
||||
<SECU/>
|
||||
<CNAM/>
|
||||
<CDAT>0000-00-00</CDAT>
|
||||
<UNAM/>
|
||||
<UDAT>0000-00-00</UDAT>
|
||||
<VERN/>
|
||||
<LEVL/>
|
||||
<RSTAT/>
|
||||
<RMAND/>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT/>
|
||||
<SSET/>
|
||||
<SDATE>0000-00-00</SDATE>
|
||||
<STIME/>
|
||||
<IDATE>0000-00-00</IDATE>
|
||||
<ITIME/>
|
||||
<LDBNAME/>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_SERVICES_ABAPGIT</ENTRY>
|
||||
<LENGTH>33</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
64
src/zabapgit_services_db.prog.abap
Normal file
64
src/zabapgit_services_db.prog.abap
Normal file
|
@ -0,0 +1,64 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_SERVICES_DB
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_services_db DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
|
||||
CLASS-METHODS delete
|
||||
IMPORTING is_key TYPE lcl_persistence_db=>ty_content
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS update
|
||||
IMPORTING is_content TYPE lcl_persistence_db=>ty_content
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS. "lcl_services_db
|
||||
|
||||
CLASS lcl_services_db IMPLEMENTATION.
|
||||
|
||||
METHOD delete.
|
||||
|
||||
DATA: lv_answer TYPE c LENGTH 1.
|
||||
|
||||
ASSERT is_key-type IS NOT INITIAL.
|
||||
ASSERT is_key-value IS NOT INITIAL.
|
||||
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Warning'
|
||||
text_question = 'Delete?'
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>db( )->delete(
|
||||
iv_type = is_key-type
|
||||
iv_value = is_key-value ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. " delete
|
||||
|
||||
METHOD update.
|
||||
|
||||
ASSERT is_content-type IS NOT INITIAL.
|
||||
ASSERT is_content-value IS NOT INITIAL.
|
||||
|
||||
lcl_app=>db( )->update(
|
||||
iv_type = is_content-type
|
||||
iv_value = is_content-value
|
||||
iv_data = is_content-data_str ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "update
|
||||
|
||||
ENDCLASS. "lcl_services_db
|
48
src/zabapgit_services_db.prog.xml
Normal file
48
src/zabapgit_services_db.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_SERVICES_DB</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
<VARCL>X</VARCL>
|
||||
<DBAPL/>
|
||||
<DBNA/>
|
||||
<CLAS/>
|
||||
<TYPE/>
|
||||
<OCCURS/>
|
||||
<SUBC>I</SUBC>
|
||||
<APPL/>
|
||||
<SECU/>
|
||||
<CNAM/>
|
||||
<CDAT>0000-00-00</CDAT>
|
||||
<UNAM/>
|
||||
<UDAT>0000-00-00</UDAT>
|
||||
<VERN/>
|
||||
<LEVL/>
|
||||
<RSTAT/>
|
||||
<RMAND/>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT/>
|
||||
<SSET/>
|
||||
<SDATE>0000-00-00</SDATE>
|
||||
<STIME/>
|
||||
<IDATE>0000-00-00</IDATE>
|
||||
<ITIME/>
|
||||
<LDBNAME/>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_SERVICES_DB</ENTRY>
|
||||
<LENGTH>28</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
166
src/zabapgit_services_git.prog.abap
Normal file
166
src/zabapgit_services_git.prog.abap
Normal file
|
@ -0,0 +1,166 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_SERVICES_GIT
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_services_git DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS pull
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS reset
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS create_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS switch_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS delete_branch
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
ENDCLASS. " lcl_services_git
|
||||
|
||||
CLASS lcl_services_git IMPLEMENTATION.
|
||||
|
||||
METHOD reset.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
lv_answer TYPE c LENGTH 1.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot reset. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Warning'
|
||||
text_question = 'Reset local objects?'
|
||||
text_button_1 = 'Ok'
|
||||
icon_button_1 = 'ICON_OKAY'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD create_branch.
|
||||
|
||||
DATA: lv_name TYPE string,
|
||||
lv_cancel TYPE abap_bool,
|
||||
lo_repo TYPE REF TO lcl_repo_online.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
lcl_popups=>create_branch_popup(
|
||||
IMPORTING
|
||||
ev_name = lv_name
|
||||
ev_cancel = lv_cancel ).
|
||||
IF lv_cancel = abap_true.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
ASSERT lv_name CP 'refs/heads/+*'.
|
||||
|
||||
lcl_git_porcelain=>create_branch(
|
||||
io_repo = lo_repo
|
||||
iv_name = lv_name
|
||||
iv_from = lo_repo->get_sha1_local( ) ).
|
||||
|
||||
" automatically switch to new branch
|
||||
lo_repo->set_branch_name( lv_name ).
|
||||
|
||||
MESSAGE 'Switched to new branch' TYPE 'S' ##NO_TEXT.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pull.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online.
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot pull. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lo_repo->refresh( ).
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "pull
|
||||
|
||||
METHOD switch_branch.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_branch TYPE lcl_git_branch_list=>ty_git_branch.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
ls_branch = lcl_popups=>branch_list_popup(
|
||||
iv_url = lo_repo->get_url( )
|
||||
iv_default_branch = lo_repo->get_branch_name( )
|
||||
iv_show_new_option = abap_true ).
|
||||
IF ls_branch IS INITIAL.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
IF ls_branch-name = lcl_popups=>c_new_branch_label.
|
||||
create_branch( iv_key ).
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
lo_repo->set_branch_name( ls_branch-name ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
ENDMETHOD. "switch_branch
|
||||
|
||||
METHOD delete_branch.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_branch TYPE lcl_git_branch_list=>ty_git_branch.
|
||||
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
ls_branch = lcl_popups=>branch_list_popup( lo_repo->get_url( ) ).
|
||||
IF ls_branch IS INITIAL.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
IF ls_branch-name = 'HEAD'.
|
||||
lcx_exception=>raise( 'Cannot delete HEAD' ).
|
||||
ELSEIF ls_branch-name = lo_repo->get_branch_name( ).
|
||||
lcx_exception=>raise( 'Switch branch before deleting current' ).
|
||||
ENDIF.
|
||||
|
||||
lcl_git_porcelain=>delete_branch(
|
||||
io_repo = lo_repo
|
||||
is_branch = ls_branch ).
|
||||
|
||||
MESSAGE 'Branch deleted' TYPE 'S'.
|
||||
|
||||
ENDMETHOD. "delete_branch
|
||||
|
||||
ENDCLASS. " lcl_services_git
|
48
src/zabapgit_services_git.prog.xml
Normal file
48
src/zabapgit_services_git.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_SERVICES_GIT</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
<VARCL>X</VARCL>
|
||||
<DBAPL/>
|
||||
<DBNA/>
|
||||
<CLAS/>
|
||||
<TYPE/>
|
||||
<OCCURS/>
|
||||
<SUBC>I</SUBC>
|
||||
<APPL/>
|
||||
<SECU/>
|
||||
<CNAM/>
|
||||
<CDAT>0000-00-00</CDAT>
|
||||
<UNAM/>
|
||||
<UDAT>0000-00-00</UDAT>
|
||||
<VERN/>
|
||||
<LEVL/>
|
||||
<RSTAT/>
|
||||
<RMAND/>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT/>
|
||||
<SSET/>
|
||||
<SDATE>0000-00-00</SDATE>
|
||||
<STIME/>
|
||||
<IDATE>0000-00-00</IDATE>
|
||||
<ITIME/>
|
||||
<LDBNAME/>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_SERVICES_GIT</ENTRY>
|
||||
<LENGTH>29</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
162
src/zabapgit_services_repo.prog.abap
Normal file
162
src/zabapgit_services_repo.prog.abap
Normal file
|
@ -0,0 +1,162 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_SERVICES_REPO
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_services_repo DEFINITION FINAL.
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS clone
|
||||
IMPORTING iv_url TYPE string
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS refresh
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS remove
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS purge
|
||||
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
CLASS-METHODS new_offline
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
ENDCLASS. "lcl_services_repo
|
||||
|
||||
CLASS lcl_services_repo IMPLEMENTATION.
|
||||
|
||||
METHOD clone.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_popup TYPE lcl_popups=>ty_popup.
|
||||
|
||||
|
||||
ls_popup = lcl_popups=>repo_popup( iv_url ).
|
||||
IF ls_popup-cancel = abap_true.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->new_online(
|
||||
iv_url = ls_popup-url
|
||||
iv_branch_name = ls_popup-branch_name
|
||||
iv_package = ls_popup-package ).
|
||||
lo_repo->status( ). " check for errors
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
lcl_app=>user( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "clone
|
||||
|
||||
METHOD refresh.
|
||||
|
||||
lcl_app=>repo_srv( )->get( iv_key )->refresh( ).
|
||||
|
||||
ENDMETHOD. "refresh
|
||||
|
||||
METHOD remove.
|
||||
|
||||
DATA: lv_answer TYPE c LENGTH 1,
|
||||
lo_repo TYPE REF TO lcl_repo,
|
||||
lv_package TYPE devclass,
|
||||
lv_question TYPE c LENGTH 200.
|
||||
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->get( iv_key ).
|
||||
lv_package = lo_repo->get_package( ).
|
||||
lv_question = |This will remove the repository reference to the package { lv_package }|
|
||||
&& '. All objects will safely remain in the system.'.
|
||||
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Remove'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Remove'
|
||||
icon_button_1 = 'ICON_WF_UNLINK'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>repo_srv( )->delete( lo_repo ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "remove
|
||||
|
||||
METHOD purge.
|
||||
|
||||
DATA: lt_tadir TYPE ty_tadir_tt,
|
||||
lv_answer TYPE c LENGTH 1,
|
||||
lo_repo TYPE REF TO lcl_repo,
|
||||
lv_package TYPE devclass,
|
||||
lv_question TYPE c LENGTH 100.
|
||||
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot purge. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lv_package = lo_repo->get_package( ).
|
||||
lt_tadir = lcl_tadir=>read( lv_package ).
|
||||
|
||||
IF lines( lt_tadir ) > 0.
|
||||
|
||||
lv_question = |This will DELETE all objects in package { lv_package }|
|
||||
&& | ({ lines( lt_tadir ) } objects) from the system|. "#EC NOTEXT
|
||||
|
||||
lv_answer = lcl_popups=>popup_to_confirm(
|
||||
titlebar = 'Uninstall'
|
||||
text_question = lv_question
|
||||
text_button_1 = 'Delete'
|
||||
icon_button_1 = 'ICON_DELETE'
|
||||
text_button_2 = 'Cancel'
|
||||
icon_button_2 = 'ICON_CANCEL'
|
||||
default_button = '2'
|
||||
display_cancel_button = abap_false
|
||||
). "#EC NOTEXT
|
||||
|
||||
IF lv_answer = '2'.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lcl_objects=>delete( lt_tadir ).
|
||||
|
||||
ENDIF.
|
||||
|
||||
lcl_app=>repo_srv( )->delete( lo_repo ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "purge
|
||||
|
||||
METHOD new_offline.
|
||||
|
||||
DATA: lo_repo TYPE REF TO lcl_repo,
|
||||
ls_popup TYPE lcl_popups=>ty_popup.
|
||||
|
||||
ls_popup = lcl_popups=>repo_new_offline( ).
|
||||
IF ls_popup-cancel = abap_true.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
lo_repo = lcl_app=>repo_srv( )->new_offline(
|
||||
iv_url = ls_popup-url
|
||||
iv_package = ls_popup-package ).
|
||||
|
||||
lcl_app=>user( )->set_repo_show( lo_repo->get_key( ) ). " Set default repo for user
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "new_offline
|
||||
|
||||
ENDCLASS. "lcl_services_repo
|
48
src/zabapgit_services_repo.prog.xml
Normal file
48
src/zabapgit_services_repo.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_SERVICES_REPO</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
<VARCL>X</VARCL>
|
||||
<DBAPL/>
|
||||
<DBNA/>
|
||||
<CLAS/>
|
||||
<TYPE/>
|
||||
<OCCURS/>
|
||||
<SUBC>I</SUBC>
|
||||
<APPL/>
|
||||
<SECU/>
|
||||
<CNAM/>
|
||||
<CDAT>0000-00-00</CDAT>
|
||||
<UNAM/>
|
||||
<UDAT>0000-00-00</UDAT>
|
||||
<VERN/>
|
||||
<LEVL/>
|
||||
<RSTAT/>
|
||||
<RMAND/>
|
||||
<RLOAD>E</RLOAD>
|
||||
<FIXPT/>
|
||||
<SSET/>
|
||||
<SDATE>0000-00-00</SDATE>
|
||||
<STIME/>
|
||||
<IDATE>0000-00-00</IDATE>
|
||||
<ITIME/>
|
||||
<LDBNAME/>
|
||||
<UCCHECK>X</UCCHECK>
|
||||
</PROGDIR>
|
||||
<TPOOL>
|
||||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_SERVICES_REPO</ENTRY>
|
||||
<LENGTH>30</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
|
@ -16,10 +16,12 @@ CLASS lcl_zip DEFINITION FINAL.
|
|||
|
||||
CLASS-METHODS export
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo
|
||||
iv_zip TYPE abap_bool DEFAULT abap_true
|
||||
it_filter TYPE scts_tadir OPTIONAL
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS export_package
|
||||
RAISING lcx_exception lcx_cancel.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CLASS-METHODS file_upload
|
||||
|
@ -41,10 +43,6 @@ CLASS lcl_zip DEFINITION FINAL.
|
|||
iv_xstr TYPE xstring
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS files_commit
|
||||
IMPORTING it_files TYPE ty_files_item_tt
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS encode_files
|
||||
IMPORTING it_files TYPE ty_files_item_tt
|
||||
RETURNING VALUE(rv_xstr) TYPE xstring
|
||||
|
@ -364,12 +362,8 @@ CLASS lcl_zip IMPLEMENTATION.
|
|||
ENDLOOP.
|
||||
ENDIF.
|
||||
|
||||
IF iv_zip = abap_true.
|
||||
file_download( iv_package = io_repo->get_package( )
|
||||
iv_xstr = encode_files( lt_zip ) ).
|
||||
ELSE.
|
||||
files_commit( lt_zip ).
|
||||
ENDIF.
|
||||
file_download( iv_package = io_repo->get_package( )
|
||||
iv_xstr = encode_files( lt_zip ) ).
|
||||
|
||||
ENDMETHOD. "export_key
|
||||
|
||||
|
@ -384,125 +378,25 @@ CLASS lcl_zip IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "import
|
||||
|
||||
METHOD files_commit.
|
||||
METHOD export_package.
|
||||
|
||||
DATA: lv_folder TYPE string,
|
||||
lv_filename TYPE string,
|
||||
lv_par TYPE string,
|
||||
lv_message TYPE string,
|
||||
lt_rawdata TYPE solix_tab.
|
||||
DATA: lo_repo TYPE REF TO lcl_repo_offline,
|
||||
ls_data TYPE lcl_persistence_repo=>ty_repo.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF it_files.
|
||||
ls_data-package = lcl_popups=>popup_package_export( ).
|
||||
IF ls_data-package IS INITIAL.
|
||||
RAISE EXCEPTION TYPE lcx_cancel.
|
||||
ENDIF.
|
||||
|
||||
ls_data-key = 'DUMMY'.
|
||||
ls_data-master_language = sy-langu.
|
||||
|
||||
cl_gui_frontend_services=>directory_browse(
|
||||
CREATE OBJECT lo_repo
|
||||
EXPORTING
|
||||
window_title = 'Select folder'
|
||||
CHANGING
|
||||
selected_folder = lv_folder
|
||||
EXCEPTIONS
|
||||
cntl_error = 1
|
||||
error_no_gui = 2
|
||||
not_supported_by_gui = 3
|
||||
OTHERS = 4 ). "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from directory_browser' ).
|
||||
ENDIF.
|
||||
is_data = ls_data.
|
||||
|
||||
IF lv_folder IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lcl_zip=>export( lo_repo ).
|
||||
|
||||
lv_message = get_message( ).
|
||||
|
||||
LOOP AT it_files ASSIGNING <ls_file>.
|
||||
lt_rawdata = cl_bcs_convert=>xstring_to_solix( <ls_file>-file-data ).
|
||||
|
||||
CONCATENATE lv_folder <ls_file>-file-path <ls_file>-file-filename INTO lv_filename.
|
||||
|
||||
cl_gui_frontend_services=>gui_download(
|
||||
EXPORTING
|
||||
bin_filesize = xstrlen( <ls_file>-file-data )
|
||||
filename = lv_filename
|
||||
filetype = 'BIN'
|
||||
CHANGING
|
||||
data_tab = lt_rawdata
|
||||
EXCEPTIONS
|
||||
file_write_error = 1
|
||||
no_batch = 2
|
||||
gui_refuse_filetransfer = 3
|
||||
invalid_type = 4
|
||||
no_authority = 5
|
||||
unknown_error = 6
|
||||
header_not_allowed = 7
|
||||
separator_not_allowed = 8
|
||||
filesize_not_allowed = 9
|
||||
header_too_long = 10
|
||||
dp_error_create = 11
|
||||
dp_error_send = 12
|
||||
dp_error_write = 13
|
||||
unknown_dp_error = 14
|
||||
access_denied = 15
|
||||
dp_out_of_memory = 16
|
||||
disk_full = 17
|
||||
dp_timeout = 18
|
||||
file_not_found = 19
|
||||
dataprovider_exception = 20
|
||||
control_flush_error = 21
|
||||
not_supported_by_gui = 22
|
||||
error_no_gui = 23
|
||||
OTHERS = 24 ).
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from gui_download' ).
|
||||
ENDIF.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
* assumption: git command is in PATH
|
||||
cl_gui_frontend_services=>execute(
|
||||
EXPORTING
|
||||
application = 'git'
|
||||
default_directory = lv_folder
|
||||
synchronous = 'X'
|
||||
parameter = 'add *'
|
||||
EXCEPTIONS
|
||||
cntl_error = 1
|
||||
error_no_gui = 2
|
||||
bad_parameter = 3
|
||||
file_not_found = 4
|
||||
path_not_found = 5
|
||||
file_extension_unknown = 6
|
||||
error_execute_failed = 7
|
||||
synchronous_failed = 8
|
||||
not_supported_by_gui = 9
|
||||
OTHERS = 10 ). "#EC NOTEXT
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from execute' ).
|
||||
ENDIF.
|
||||
|
||||
* make sure to set git user.email and user.name manually
|
||||
lv_par = 'commit -m "' && lv_message && '"'. "#EC NOTEXT
|
||||
cl_gui_frontend_services=>execute(
|
||||
EXPORTING
|
||||
application = 'git'
|
||||
default_directory = lv_folder
|
||||
synchronous = 'X'
|
||||
parameter = lv_par
|
||||
EXCEPTIONS
|
||||
cntl_error = 1
|
||||
error_no_gui = 2
|
||||
bad_parameter = 3
|
||||
file_not_found = 4
|
||||
path_not_found = 5
|
||||
file_extension_unknown = 6
|
||||
error_execute_failed = 7
|
||||
synchronous_failed = 8
|
||||
not_supported_by_gui = 9
|
||||
OTHERS = 10 ).
|
||||
IF sy-subrc <> 0.
|
||||
lcx_exception=>raise( 'error from execute' ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "files_commit
|
||||
ENDMETHOD. "export_package
|
||||
|
||||
ENDCLASS. "lcl_zip IMPLEMENTATION
|
Loading…
Reference in New Issue
Block a user