mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
* refactor most regarding commit and staging * use gitgraph 1.2.3 * move db gui to new include * allow specifying branch * move target branch to stage object * git, get rid of reference to repo * merge now working #275 cleanup
This commit is contained in:
parent
af74a24b6d
commit
5f7d851de5
|
@ -60,7 +60,7 @@ INCLUDE zabapgit_sap_package.
|
|||
CLASS lcl_repo_online DEFINITION DEFERRED.
|
||||
INCLUDE zabapgit_stage.
|
||||
INCLUDE zabapgit_repo.
|
||||
INCLUDE zabapgit_stage_impl.
|
||||
INCLUDE zabapgit_stage_logic.
|
||||
INCLUDE zabapgit_git.
|
||||
INCLUDE zabapgit_objects.
|
||||
INCLUDE zabapgit_tadir.
|
||||
|
@ -72,9 +72,11 @@ INCLUDE zabapgit_background.
|
|||
INCLUDE zabapgit_zip.
|
||||
INCLUDE zabapgit_transport.
|
||||
INCLUDE zabapgit_page.
|
||||
INCLUDE zabapgit_page_commit.
|
||||
INCLUDE zabapgit_page_merge.
|
||||
INCLUDE zabapgit_page_branch_overview.
|
||||
INCLUDE zabapgit_page_commit.
|
||||
INCLUDE zabapgit_page_stage.
|
||||
INCLUDE zabapgit_page_db.
|
||||
INCLUDE zabapgit_gui.
|
||||
INCLUDE zabapgit_app_impl.
|
||||
INCLUDE zabapgit_unit_test.
|
||||
|
|
|
@ -20,7 +20,7 @@ CLASS lcl_background IMPLEMENTATION.
|
|||
METHOD push.
|
||||
|
||||
DATA: ls_comment TYPE ty_comment,
|
||||
ls_files TYPE lcl_stage_logic=>ty_stage_files,
|
||||
ls_files TYPE ty_stage_files,
|
||||
lo_stage TYPE REF TO lcl_stage.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF ls_files-local.
|
||||
|
@ -36,12 +36,16 @@ CLASS lcl_background IMPLEMENTATION.
|
|||
ls_comment-email = 'foo@bar.com' ##NO_TEXT.
|
||||
ls_comment-comment = 'background mode' ##NO_TEXT.
|
||||
|
||||
lo_stage = lcl_app=>repo_srv( )->get_stage( io_repo->get_key( ) ).
|
||||
CREATE OBJECT lo_stage
|
||||
EXPORTING
|
||||
iv_branch_name = io_repo->get_branch_name( )
|
||||
iv_branch_sha1 = io_repo->get_sha1_remote( ).
|
||||
|
||||
LOOP AT ls_files-local ASSIGNING <ls_file>.
|
||||
WRITE: / 'stage', <ls_file>-file-path, <ls_file>-file-filename ##NO_TEXT.
|
||||
lo_stage->add( iv_path = <ls_file>-file-path
|
||||
iv_filename = <ls_file>-file-filename ).
|
||||
iv_filename = <ls_file>-file-filename
|
||||
iv_data = <ls_file>-file-data ).
|
||||
ENDLOOP.
|
||||
|
||||
io_repo->push( is_comment = ls_comment
|
||||
|
|
|
@ -54,6 +54,11 @@ TYPES: BEGIN OF ty_repo_file,
|
|||
END OF ty_repo_file.
|
||||
TYPES tt_repo_files TYPE STANDARD TABLE OF ty_repo_file WITH DEFAULT KEY.
|
||||
|
||||
TYPES: BEGIN OF ty_stage_files,
|
||||
local TYPE ty_files_item_tt,
|
||||
remote TYPE ty_files_tt,
|
||||
END OF ty_stage_files.
|
||||
|
||||
CONSTANTS: BEGIN OF gc_type,
|
||||
commit TYPE ty_type VALUE 'commit', "#EC NOTEXT
|
||||
tree TYPE ty_type VALUE 'tree', "#EC NOTEXT
|
||||
|
|
|
@ -29,7 +29,7 @@ CLASS lcl_git_transport DEFINITION FINAL.
|
|||
|
||||
* local to remote
|
||||
CLASS-METHODS receive_pack
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
IMPORTING iv_url TYPE string
|
||||
iv_old TYPE ty_sha1
|
||||
iv_new TYPE ty_sha1
|
||||
iv_branch_name TYPE string
|
||||
|
@ -64,10 +64,11 @@ CLASS lcl_git_transport DEFINITION FINAL.
|
|||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS find_branch
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
iv_service TYPE string
|
||||
EXPORTING ei_client TYPE REF TO if_http_client
|
||||
ev_branch TYPE ty_sha1
|
||||
IMPORTING iv_url TYPE string
|
||||
iv_service TYPE string
|
||||
iv_branch_name TYPE string
|
||||
EXPORTING ei_client TYPE REF TO if_http_client
|
||||
ev_branch TYPE ty_sha1
|
||||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS parse
|
||||
|
@ -86,7 +87,7 @@ CLASS lcl_git_transport DEFINITION FINAL.
|
|||
RAISING lcx_exception.
|
||||
|
||||
CLASS-METHODS set_headers
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
IMPORTING iv_url TYPE string
|
||||
iv_service TYPE string
|
||||
ii_client TYPE REF TO if_http_client
|
||||
RAISING lcx_exception.
|
||||
|
@ -214,7 +215,7 @@ CLASS lcl_git_transport IMPLEMENTATION.
|
|||
name = '~request_method'
|
||||
value = 'POST' ).
|
||||
|
||||
lv_value = lcl_url=>path_name( io_repo->get_url( ) ) &&
|
||||
lv_value = lcl_url=>path_name( iv_url ) &&
|
||||
'.git/git-' &&
|
||||
iv_service &&
|
||||
'-pack'.
|
||||
|
@ -326,23 +327,25 @@ CLASS lcl_git_transport IMPLEMENTATION.
|
|||
|
||||
branch_list(
|
||||
EXPORTING
|
||||
iv_url = io_repo->get_url( )
|
||||
iv_url = iv_url
|
||||
iv_service = iv_service
|
||||
IMPORTING
|
||||
ei_client = ei_client
|
||||
et_branch_list = lt_branch_list ).
|
||||
|
||||
IF io_repo->get_branch_name( ) IS INITIAL.
|
||||
_raise 'branch empty'.
|
||||
ENDIF.
|
||||
IF ev_branch IS SUPPLIED.
|
||||
IF iv_branch_name IS INITIAL.
|
||||
_raise 'branch empty'.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_branch_list INTO ls_branch_list
|
||||
WITH KEY name = io_repo->get_branch_name( ).
|
||||
IF sy-subrc <> 0.
|
||||
_raise 'Branch not found'.
|
||||
ENDIF.
|
||||
READ TABLE lt_branch_list INTO ls_branch_list
|
||||
WITH KEY name = iv_branch_name.
|
||||
IF sy-subrc <> 0.
|
||||
_raise 'Branch not found'.
|
||||
ENDIF.
|
||||
|
||||
ev_branch = ls_branch_list-sha1.
|
||||
ev_branch = ls_branch_list-sha1.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "find_branch
|
||||
|
||||
|
@ -445,13 +448,14 @@ CLASS lcl_git_transport IMPLEMENTATION.
|
|||
|
||||
find_branch(
|
||||
EXPORTING
|
||||
io_repo = io_repo
|
||||
iv_service = c_service-receive
|
||||
iv_url = iv_url
|
||||
iv_service = c_service-receive
|
||||
iv_branch_name = iv_branch_name
|
||||
IMPORTING
|
||||
ei_client = li_client ).
|
||||
ei_client = li_client ).
|
||||
|
||||
set_headers(
|
||||
io_repo = io_repo
|
||||
iv_url = iv_url
|
||||
iv_service = c_service-receive
|
||||
ii_client = li_client ).
|
||||
|
||||
|
@ -576,11 +580,12 @@ CLASS lcl_git_transport IMPLEMENTATION.
|
|||
|
||||
find_branch(
|
||||
EXPORTING
|
||||
io_repo = io_repo
|
||||
iv_service = c_service-upload
|
||||
iv_url = io_repo->get_url( )
|
||||
iv_service = c_service-upload
|
||||
iv_branch_name = io_repo->get_branch_name( )
|
||||
IMPORTING
|
||||
ei_client = li_client
|
||||
ev_branch = ev_branch ).
|
||||
ei_client = li_client
|
||||
ev_branch = ev_branch ).
|
||||
|
||||
IF it_branches IS INITIAL.
|
||||
APPEND INITIAL LINE TO lt_branches ASSIGNING <ls_branch>.
|
||||
|
@ -589,7 +594,7 @@ CLASS lcl_git_transport IMPLEMENTATION.
|
|||
lt_branches = it_branches.
|
||||
ENDIF.
|
||||
|
||||
set_headers( io_repo = io_repo
|
||||
set_headers( iv_url = io_repo->get_url( )
|
||||
iv_service = c_service-upload
|
||||
ii_client = li_client ).
|
||||
|
||||
|
@ -818,15 +823,24 @@ CLASS lcl_git_pack IMPLEMENTATION.
|
|||
lv_tree_lower = is_commit-tree.
|
||||
TRANSLATE lv_tree_lower TO LOWER CASE.
|
||||
|
||||
lv_parent_lower = is_commit-parent.
|
||||
TRANSLATE lv_parent_lower TO LOWER CASE.
|
||||
|
||||
lv_string = ''.
|
||||
|
||||
CONCATENATE 'tree' lv_tree_lower INTO lv_tmp SEPARATED BY space. "#EC NOTEXT
|
||||
CONCATENATE lv_string lv_tmp gc_newline INTO lv_string.
|
||||
|
||||
IF NOT is_commit-parent IS INITIAL.
|
||||
lv_parent_lower = is_commit-parent.
|
||||
TRANSLATE lv_parent_lower TO LOWER CASE.
|
||||
|
||||
CONCATENATE 'parent' lv_parent_lower
|
||||
INTO lv_tmp SEPARATED BY space. "#EC NOTEXT
|
||||
CONCATENATE lv_string lv_tmp gc_newline INTO lv_string.
|
||||
ENDIF.
|
||||
|
||||
IF NOT is_commit-parent2 IS INITIAL.
|
||||
lv_parent_lower = is_commit-parent2.
|
||||
TRANSLATE lv_parent_lower TO LOWER CASE.
|
||||
|
||||
CONCATENATE 'parent' lv_parent_lower
|
||||
INTO lv_tmp SEPARATED BY space. "#EC NOTEXT
|
||||
CONCATENATE lv_string lv_tmp gc_newline INTO lv_string.
|
||||
|
@ -1404,7 +1418,7 @@ CLASS lcl_git_porcelain DEFINITION FINAL FRIENDS ltcl_git_porcelain.
|
|||
io_repo TYPE REF TO lcl_repo_online
|
||||
it_trees TYPE ty_trees_tt
|
||||
it_blobs TYPE ty_files_tt
|
||||
iv_branch TYPE ty_sha1
|
||||
io_stage TYPE REF TO lcl_stage
|
||||
RETURNING VALUE(rv_branch) TYPE ty_sha1
|
||||
RAISING lcx_exception.
|
||||
|
||||
|
@ -1437,7 +1451,8 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
|
||||
* new commit
|
||||
ls_commit-tree = <ls_tree>-sha1.
|
||||
ls_commit-parent = iv_branch.
|
||||
ls_commit-parent = io_stage->get_branch_sha1( ).
|
||||
ls_commit-parent2 = io_stage->get_merge_source( ).
|
||||
CONCATENATE is_comment-username space '<' is_comment-email '>' space lv_time
|
||||
INTO ls_commit-author RESPECTING BLANKS.
|
||||
ls_commit-committer = ls_commit-author.
|
||||
|
@ -1462,6 +1477,7 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
CLEAR ls_object.
|
||||
ls_object-sha1 = lcl_hash=>sha1( iv_type = gc_type-blob iv_data = <ls_blob>-data ).
|
||||
ls_object-type = gc_type-blob.
|
||||
ASSERT NOT <ls_blob>-data IS INITIAL.
|
||||
ls_object-data = <ls_blob>-data.
|
||||
APPEND ls_object TO lt_objects.
|
||||
ENDLOOP.
|
||||
|
@ -1473,10 +1489,10 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
iv_data = lv_commit ).
|
||||
|
||||
lcl_git_transport=>receive_pack(
|
||||
io_repo = io_repo
|
||||
iv_old = io_repo->get_sha1_local( )
|
||||
iv_url = io_repo->get_url( )
|
||||
iv_old = io_stage->get_branch_sha1( )
|
||||
iv_new = rv_branch
|
||||
iv_branch_name = io_repo->get_branch_name( )
|
||||
iv_branch_name = io_stage->get_branch_name( )
|
||||
iv_pack = lv_pack ).
|
||||
|
||||
ENDMETHOD. "receive_pack
|
||||
|
@ -1495,7 +1511,7 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
lv_pack = lcl_git_pack=>encode( lt_objects ).
|
||||
|
||||
lcl_git_transport=>receive_pack(
|
||||
io_repo = io_repo
|
||||
iv_url = io_repo->get_url( )
|
||||
iv_old = lv_zero
|
||||
iv_new = iv_from
|
||||
iv_branch_name = iv_name
|
||||
|
@ -1509,14 +1525,30 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
lt_blobs TYPE ty_files_tt,
|
||||
lv_sha1 TYPE ty_sha1,
|
||||
lt_trees TYPE ty_trees_tt,
|
||||
lt_objects TYPE ty_objects_tt,
|
||||
lt_branches TYPE lcl_git_transport=>ty_branch_list_tt,
|
||||
lt_stage TYPE lcl_stage=>ty_stage_tt.
|
||||
|
||||
FIELD-SYMBOLS: <ls_stage> LIKE LINE OF lt_stage,
|
||||
<ls_exp> LIKE LINE OF lt_expanded.
|
||||
FIELD-SYMBOLS: <ls_stage> LIKE LINE OF lt_stage,
|
||||
<ls_branch> LIKE LINE OF lt_branches,
|
||||
<ls_exp> LIKE LINE OF lt_expanded.
|
||||
|
||||
|
||||
lt_expanded = full_tree( it_objects = io_repo->get_objects( )
|
||||
iv_branch = io_repo->get_sha1_remote( ) ).
|
||||
IF io_stage->get_branch_sha1( ) = io_repo->get_sha1_remote( ).
|
||||
* objects cached in io_repo can be used, if pushing to the branch configured in repo
|
||||
lt_objects = io_repo->get_objects( ).
|
||||
ELSE.
|
||||
APPEND INITIAL LINE TO lt_branches ASSIGNING <ls_branch>.
|
||||
<ls_branch>-name = io_stage->get_branch_name( ).
|
||||
<ls_branch>-sha1 = io_stage->get_branch_sha1( ).
|
||||
|
||||
lcl_git_transport=>upload_pack( EXPORTING io_repo = io_repo
|
||||
it_branches = lt_branches
|
||||
IMPORTING et_objects = lt_objects ).
|
||||
ENDIF.
|
||||
|
||||
lt_expanded = full_tree( it_objects = lt_objects
|
||||
iv_branch = io_stage->get_branch_sha1( ) ).
|
||||
|
||||
lt_stage = io_stage->get_all( ).
|
||||
LOOP AT lt_stage ASSIGNING <ls_stage>.
|
||||
|
@ -1534,7 +1566,8 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
<ls_exp>-chmod = gc_chmod-file.
|
||||
ENDIF.
|
||||
|
||||
lv_sha1 = lcl_hash=>sha1( iv_type = gc_type-blob iv_data = <ls_stage>-file-data ).
|
||||
lv_sha1 = lcl_hash=>sha1( iv_type = gc_type-blob
|
||||
iv_data = <ls_stage>-file-data ).
|
||||
IF <ls_exp>-sha1 <> lv_sha1.
|
||||
<ls_exp>-sha1 = lv_sha1.
|
||||
ENDIF.
|
||||
|
@ -1554,7 +1587,7 @@ CLASS lcl_git_porcelain IMPLEMENTATION.
|
|||
io_repo = io_repo
|
||||
it_trees = lt_trees
|
||||
it_blobs = lt_blobs
|
||||
iv_branch = io_repo->get_sha1_remote( ) ).
|
||||
io_stage = io_stage ).
|
||||
|
||||
ENDMETHOD. "push
|
||||
|
||||
|
|
|
@ -52,11 +52,6 @@ CLASS lcl_gui_router DEFINITION FINAL.
|
|||
RETURNING VALUE(ri_page) TYPE REF TO lif_gui_page
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS get_page_commit
|
||||
IMPORTING iv_getdata TYPE clike
|
||||
RETURNING VALUE(ri_page) TYPE REF TO lif_gui_page
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS get_page_db_by_name
|
||||
IMPORTING iv_name TYPE clike
|
||||
iv_getdata TYPE clike
|
||||
|
@ -113,15 +108,6 @@ CLASS lcl_gui_router DEFINITION FINAL.
|
|||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS commit_push
|
||||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS stage_handle_action
|
||||
IMPORTING iv_getdata TYPE clike
|
||||
iv_action TYPE clike
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -909,11 +895,11 @@ CLASS lcl_gui_page_background IMPLEMENTATION.
|
|||
CLEAR lv_nothing.
|
||||
CASE ls_per-method.
|
||||
WHEN lcl_persistence_background=>c_method-push.
|
||||
lv_push = ' checked'.
|
||||
lv_push = ' checked' ##NO_TEXT.
|
||||
WHEN lcl_persistence_background=>c_method-pull.
|
||||
lv_pull = ' checked'.
|
||||
lv_pull = ' checked' ##NO_TEXT.
|
||||
WHEN OTHERS.
|
||||
lv_nothing = ' checked'.
|
||||
lv_nothing = ' checked' ##NO_TEXT.
|
||||
ENDCASE.
|
||||
|
||||
ro_html->add( '<h1>' && lo_online->get_name( ) && '</h1>' ).
|
||||
|
@ -972,197 +958,6 @@ CLASS lcl_gui_page_background IMPLEMENTATION.
|
|||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_stage DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS constructor
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: mo_repo TYPE REF TO lcl_repo_online,
|
||||
mo_stage TYPE REF TO lcl_stage.
|
||||
|
||||
METHODS render_lines
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS render_menu
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_stage IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
super->constructor( ).
|
||||
mo_repo = io_repo.
|
||||
mo_stage = lcl_app=>repo_srv( )->get_stage( iv_repo_key = mo_repo->get_key( )
|
||||
iv_new = abap_true ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD render_lines.
|
||||
|
||||
DATA: lv_method TYPE lcl_stage=>ty_method,
|
||||
lv_param TYPE string,
|
||||
lv_status TYPE string,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF mo_stage->mt_workarea.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
|
||||
LOOP AT mo_stage->mt_workarea ASSIGNING <ls_file>.
|
||||
|
||||
AT NEW type. " Local/remote header line
|
||||
IF sy-tabix = 1.
|
||||
ro_html->add('<tr class="separator firstrow">').
|
||||
ELSE.
|
||||
ro_html->add('<tr class="separator">').
|
||||
ENDIF.
|
||||
IF <ls_file>-type = lcl_stage=>c_wftype-local.
|
||||
ro_html->add( '<td></td><td colspan="2">LOCAL</td>' ) ##NO_TEXT.
|
||||
ELSE. "c_remote
|
||||
ro_html->add( '<td></td><td colspan="2">REMOTE</td>' ) ##NO_TEXT.
|
||||
ENDIF.
|
||||
ro_html->add('</tr>').
|
||||
ENDAT.
|
||||
|
||||
lv_method = mo_stage->lookup( iv_path = <ls_file>-file-path
|
||||
iv_filename = <ls_file>-file-filename ).
|
||||
lv_param = lcl_html_action_utils=>file_encode( iv_key = mo_repo->get_key( )
|
||||
ig_file = <ls_file>-file ).
|
||||
|
||||
lo_toolbar->reset( ). " Build line actions
|
||||
IF <ls_file>-type = lcl_stage=>c_wftype-local.
|
||||
IF lv_method IS NOT INITIAL.
|
||||
lo_toolbar->add( iv_txt = 'reset'
|
||||
iv_act = 'stage_reset?' && lv_param ) ##NO_TEXT.
|
||||
ELSE.
|
||||
lo_toolbar->add( iv_txt = 'add'
|
||||
iv_act = 'stage_add?' && lv_param ) ##NO_TEXT.
|
||||
ENDIF.
|
||||
ELSE. "c_remote
|
||||
IF lv_method IS NOT INITIAL.
|
||||
lo_toolbar->add( iv_txt = 'reset' iv_act = 'stage_reset?' && lv_param ).
|
||||
ELSE.
|
||||
lo_toolbar->add( iv_txt = 'ignore' iv_act = 'stage_ignore?' && lv_param ).
|
||||
lo_toolbar->add( iv_txt = 'remove' iv_act = 'stage_rm?' && lv_param ).
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
IF lv_method IS INITIAL.
|
||||
lv_status = '<span class="grey">?</span>'.
|
||||
ELSE.
|
||||
lv_status = lv_method.
|
||||
ENDIF.
|
||||
|
||||
ro_html->add( '<tr>' ).
|
||||
ro_html->add( |<td class="status">{ lv_status }</td>| ).
|
||||
ro_html->add( |<td>{ <ls_file>-file-path && <ls_file>-file-filename }</td>| ).
|
||||
ro_html->add( '<td>' ).
|
||||
ro_html->add( lo_toolbar->render( iv_no_separator = abap_true ) ).
|
||||
ro_html->add( '</td>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD. "render_lines
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'STAGE' ) ).
|
||||
|
||||
ro_html->add( '<div class="repo">' ).
|
||||
ro_html->add( render_repo_top( mo_repo ) ).
|
||||
ro_html->add( render_menu( ) ).
|
||||
|
||||
ro_html->add( '<table class="stage_tab">' ).
|
||||
ro_html->add( render_lines( ) ).
|
||||
ro_html->add( '</table>' ).
|
||||
|
||||
ro_html->add( '</div>' ).
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD. "lif_gui_page~render
|
||||
|
||||
METHOD render_menu.
|
||||
|
||||
DATA: lo_toolbar TYPE REF TO lcl_html_toolbar,
|
||||
lv_action TYPE string.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
|
||||
lv_action = lcl_html_action_utils=>repo_key_encode( mo_repo->get_key( ) ).
|
||||
|
||||
IF mo_stage->count( ) > 0.
|
||||
lo_toolbar->add( iv_act = |stage_commit?{ lv_action }|
|
||||
iv_txt = 'Commit'
|
||||
iv_opt = gc_html_opt-emphas ) ##NO_TEXT.
|
||||
ELSEIF mo_stage->mv_local_cnt > 0.
|
||||
lo_toolbar->add( iv_act = |stage_all?{ lv_action }|
|
||||
iv_txt = 'Add all and commit') ##NO_TEXT.
|
||||
ENDIF.
|
||||
|
||||
ro_html->add( '<div class="paddings">' ).
|
||||
ro_html->add( lo_toolbar->render( ) ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ENDMETHOD. "render_menu
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* STAGE */'.
|
||||
_add '.stage_tab {'.
|
||||
_add ' border: 1px solid #DDD;'.
|
||||
_add ' background: #fff;'.
|
||||
_add ' margin-top: 0.2em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab td {'.
|
||||
_add ' border-top: 1px solid #eee;'.
|
||||
_add ' color: #333;'.
|
||||
_add ' vertical-align: middle;'.
|
||||
_add ' padding: 2px 0.5em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab td.status {'.
|
||||
_add ' width: 2em;'.
|
||||
_add ' text-align: center;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab tr.separator td {'.
|
||||
_add ' color: #BBB;'.
|
||||
_add ' font-size: 10pt;'.
|
||||
_add ' background-color: #edf2f9;'.
|
||||
_add ' padding: 4px 0.5em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab tr.firstrow td { border-top: 0px; } '.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_main IMPLEMENTATION.
|
||||
|
||||
METHOD render_obj_jump_link.
|
||||
|
@ -1455,10 +1250,10 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
CREATE OBJECT ro_html.
|
||||
|
||||
IF is_item-is_first = abap_true. " TR class
|
||||
lv_trclass = 'firstrow'.
|
||||
lv_trclass = 'firstrow' ##NO_TEXT.
|
||||
ENDIF.
|
||||
IF is_item-obj_name IS INITIAL.
|
||||
lv_trclass = lv_trclass && ' unsupported'.
|
||||
lv_trclass = lv_trclass && ' unsupported' ##NO_TEXT.
|
||||
ENDIF.
|
||||
IF lv_trclass IS NOT INITIAL.
|
||||
SHIFT lv_trclass LEFT DELETING LEADING space.
|
||||
|
@ -1727,318 +1522,6 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_display DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
METHODS: constructor
|
||||
IMPORTING is_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: ms_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_display IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
ms_key = is_key.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lv_data TYPE lcl_persistence_db=>ty_content-data_str.
|
||||
|
||||
TRY.
|
||||
lv_data = lcl_app=>db( )->read(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
CATCH lcx_not_found ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
|
||||
lv_data = lcl_xml_pretty=>print( lv_data ).
|
||||
|
||||
lv_data = escape( val = lv_data
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'CONFIG DISPLAY' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_entry">' ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Type:</td>| &&
|
||||
| <td>{ ms_key-type }</td></tr></table>| ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Value:</td>| &&
|
||||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
ro_html->add( |<pre>{ lv_data }</pre>| ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRY DISPLAY */'.
|
||||
_add 'div.db_entry {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
|
||||
_add 'div.db_entry pre {'.
|
||||
_add ' display: block;'.
|
||||
_add ' overflow: hidden;'.
|
||||
_add ' word-wrap:break-word;'.
|
||||
_add ' white-space: pre-wrap;'.
|
||||
_add ' background-color: #eaeaea;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add ' width: 50em;'.
|
||||
_add '}'.
|
||||
|
||||
_add 'table.tag {'.
|
||||
_add ' display: inline-block;'.
|
||||
_add ' border: 1px #b3c1cc solid;'.
|
||||
_add ' background-color: #eee;'.
|
||||
_add ' margin-right: 0.5em; '.
|
||||
_add '}'.
|
||||
_add 'table.tag td { padding: 0.2em 0.5em; }'.
|
||||
_add 'table.tag td.label { background-color: #b3c1cc; }'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_edit DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
METHODS: constructor
|
||||
IMPORTING is_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: ms_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS scripts
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_edit IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
ms_key = is_key.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lv_data TYPE lcl_persistence_db=>ty_content-data_str,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
TRY.
|
||||
lv_data = lcl_app=>db( )->read(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
CATCH lcx_not_found ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
|
||||
lcl_app=>db( )->lock(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
|
||||
lv_data = lcl_xml_pretty=>print( lv_data ).
|
||||
|
||||
lv_data = escape( val = lv_data
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'CONFIG EDIT' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_entry">' ).
|
||||
|
||||
" Banners
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Type:</td>| &&
|
||||
| <td>{ ms_key-type }</td></tr></table>| ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Value:</td>| &&
|
||||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
|
||||
" Form
|
||||
ro_html->add( '<form id="db_form" method="post" action="sapevent:db_save">' ).
|
||||
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
|
||||
}</textarea>| ).
|
||||
ro_html->add( '</form>' ).
|
||||
|
||||
" Menu
|
||||
lo_toolbar->add( iv_act = 'submitDBForm();'
|
||||
iv_txt = 'Save'
|
||||
iv_typ = gc_action_type-onclick
|
||||
iv_opt = gc_html_opt-emphas ) ##NO_TEXT.
|
||||
|
||||
ro_html->add( '<div class="paddings">' ).
|
||||
ro_html->add( lo_toolbar->render( ) ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( '</div>' ). "db_entry
|
||||
|
||||
ro_html->add( footer( io_include_script = scripts( ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRY DISPLAY */'.
|
||||
_add 'div.db_entry {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
_add 'div.db_entry textarea { margin: 0.5em 0em; }'.
|
||||
_add 'table.tag {'.
|
||||
_add ' display: inline-block;'.
|
||||
_add ' border: 1px #b3c1cc solid;'.
|
||||
_add ' background-color: #eee;'.
|
||||
_add ' margin-right: 0.5em; '.
|
||||
_add '}'.
|
||||
_add 'table.tag td { padding: 0.2em 0.5em; }'.
|
||||
_add 'table.tag td.label { background-color: #b3c1cc; }'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
METHOD scripts.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add 'function submitDBForm() {'.
|
||||
_add ' document.getElementById("db_form").submit();'.
|
||||
_add '}'.
|
||||
|
||||
ENDMETHOD. "scripts
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db IMPLEMENTATION.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lt_data TYPE lcl_persistence_db=>tt_content,
|
||||
lv_escaped TYPE string,
|
||||
lv_action TYPE string,
|
||||
lv_trclass TYPE string,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
FIELD-SYMBOLS: <ls_data> LIKE LINE OF lt_data.
|
||||
|
||||
|
||||
lt_data = lcl_app=>db( )->list( ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'DATABASE PERSISTENCY' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_list">' ).
|
||||
ro_html->add( '<table width="100%" class="db_tab">' ).
|
||||
|
||||
" Header
|
||||
ro_html->add( '<tr>' ).
|
||||
ro_html->add( '<th>Type</th>' ).
|
||||
ro_html->add( '<th>Value</th>' ).
|
||||
ro_html->add( '<th>Data</th>' ).
|
||||
ro_html->add( '<th></th>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
|
||||
" Lines
|
||||
LOOP AT lt_data ASSIGNING <ls_data>.
|
||||
CLEAR lv_trclass.
|
||||
IF sy-tabix = 1.
|
||||
lv_trclass = ' class="firstrow"'.
|
||||
ENDIF.
|
||||
|
||||
IF strlen( <ls_data>-data_str ) >= 250.
|
||||
lv_escaped = escape( val = <ls_data>-data_str(250)
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
ELSE.
|
||||
lv_escaped = escape( val = <ls_data>-data_str
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
ENDIF.
|
||||
|
||||
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 }| ).
|
||||
|
||||
ro_html->add( |<tr{ lv_trclass }>| ).
|
||||
ro_html->add( |<td>{ <ls_data>-type }</td>| ).
|
||||
ro_html->add( |<td>{ <ls_data>-value }</td>| ).
|
||||
ro_html->add( |<td><pre>{ lv_escaped }</pre></td>| ).
|
||||
ro_html->add( '<td>' ).
|
||||
ro_html->add( lo_toolbar->render( iv_vertical = abap_true ) ).
|
||||
ro_html->add( '</td>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
ENDLOOP.
|
||||
|
||||
ro_html->add( '</table>' ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD. "lif_gui_page~render
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRIES */'.
|
||||
_add 'div.db_list {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab pre {'.
|
||||
_add ' display: block;'.
|
||||
_add ' overflow: hidden;'.
|
||||
_add ' word-wrap:break-word;'.
|
||||
_add ' white-space: pre-wrap;'.
|
||||
_add ' background-color: #eaeaea;'.
|
||||
_add ' padding: 3px;'.
|
||||
_add ' width: 50em;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab tr.firstrow td { padding-top: 0.5em; }'.
|
||||
_add 'table.db_tab th {'.
|
||||
_add ' text-align: left;'.
|
||||
_add ' color: #888;'.
|
||||
_add ' padding: 0.2em;'.
|
||||
_add ' border-bottom: 1px #ddd solid;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab td {'.
|
||||
_add ' color: #333;'.
|
||||
_add ' padding: 0.2em;'.
|
||||
_add ' vertical-align: top;'.
|
||||
_add '}'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_gui_router IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -2174,26 +1657,6 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
WHEN 'branch_overview'.
|
||||
ei_page = get_page_branch_overview( iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
|
||||
" Stage
|
||||
WHEN 'stage_commit'.
|
||||
ei_page = get_page_commit( iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
WHEN 'stage_all'.
|
||||
stage_handle_action( iv_getdata = iv_getdata iv_action = iv_action ).
|
||||
ei_page = get_page_commit( iv_getdata ).
|
||||
ev_state = gc_event_state-new_page.
|
||||
WHEN 'stage_add' OR 'stage_reset' OR 'stage_ignore' OR 'stage_rm'.
|
||||
stage_handle_action( iv_getdata = iv_getdata iv_action = iv_action ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
|
||||
" Commit
|
||||
WHEN 'commit_post'.
|
||||
commit_push( it_postdata ).
|
||||
ev_state = gc_event_state-go_back_to_bookmark.
|
||||
WHEN 'commit_cancel'.
|
||||
ev_state = gc_event_state-go_back.
|
||||
|
||||
WHEN OTHERS.
|
||||
ev_state = gc_event_state-not_handled.
|
||||
ENDCASE.
|
||||
|
@ -2881,98 +2344,4 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD commit_push.
|
||||
|
||||
DATA: ls_fields TYPE lcl_html_action_utils=>ty_commit_fields,
|
||||
ls_comment TYPE ty_comment,
|
||||
lo_stage TYPE REF TO lcl_stage,
|
||||
lo_repo TYPE REF TO lcl_repo_online,
|
||||
lo_user TYPE REF TO lcl_persistence_user.
|
||||
|
||||
ls_fields = lcl_html_action_utils=>parse_commit_request( it_postdata ).
|
||||
|
||||
lo_user = lcl_app=>user( ). " TODO refactor - password manager
|
||||
lo_user->set_username( ls_fields-username ).
|
||||
lo_user->set_email( ls_fields-email ).
|
||||
|
||||
IF ls_fields-username IS INITIAL.
|
||||
_raise 'empty username'.
|
||||
ENDIF.
|
||||
IF ls_fields-email IS INITIAL.
|
||||
_raise 'empty email'.
|
||||
ENDIF.
|
||||
IF ls_fields-comment IS INITIAL.
|
||||
_raise 'empty comment'.
|
||||
ENDIF.
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( ls_fields-repo_key ).
|
||||
lo_stage = lcl_app=>repo_srv( )->get_stage( ls_fields-repo_key ).
|
||||
ls_comment-username = ls_fields-username.
|
||||
ls_comment-email = ls_fields-email.
|
||||
ls_comment-comment = ls_fields-comment.
|
||||
|
||||
IF NOT ls_fields-body IS INITIAL.
|
||||
CONCATENATE ls_comment-comment gc_newline ls_fields-body
|
||||
INTO ls_comment-comment.
|
||||
ENDIF.
|
||||
|
||||
lo_repo->push( is_comment = ls_comment
|
||||
io_stage = lo_stage ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "commit_push
|
||||
|
||||
METHOD get_page_commit.
|
||||
|
||||
DATA: lo_commit_page TYPE REF TO lcl_gui_page_commit,
|
||||
lv_key TYPE lcl_persistence_repo=>ty_repo-key.
|
||||
|
||||
lv_key = lcl_html_action_utils=>repo_key_decode( iv_getdata ).
|
||||
|
||||
CREATE OBJECT lo_commit_page
|
||||
EXPORTING
|
||||
iv_repo_key = lv_key.
|
||||
|
||||
ri_page ?= lo_commit_page.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stage_handle_action.
|
||||
|
||||
DATA: ls_file TYPE ty_file,
|
||||
lo_stage TYPE REF TO lcl_stage,
|
||||
lv_key TYPE lcl_persistence_repo=>ty_repo-key.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF lo_stage->mt_workarea.
|
||||
|
||||
IF iv_action = 'stage_all'.
|
||||
lv_key = lcl_html_action_utils=>repo_key_decode( iv_getdata ).
|
||||
ELSE.
|
||||
lcl_html_action_utils=>file_decode( EXPORTING iv_string = iv_getdata
|
||||
IMPORTING ev_key = lv_key
|
||||
eg_file = ls_file ).
|
||||
ENDIF.
|
||||
|
||||
lo_stage = lcl_app=>repo_srv( )->get_stage( lv_key ).
|
||||
|
||||
CASE iv_action.
|
||||
WHEN 'stage_add'.
|
||||
lo_stage->add( iv_path = ls_file-path iv_filename = ls_file-filename ).
|
||||
WHEN 'stage_all'.
|
||||
LOOP AT lo_stage->mt_workarea ASSIGNING <ls_file>
|
||||
WHERE type = lcl_stage=>c_wftype-local.
|
||||
lo_stage->add( iv_path = <ls_file>-file-path
|
||||
iv_filename = <ls_file>-file-filename ).
|
||||
ENDLOOP.
|
||||
WHEN 'stage_reset'.
|
||||
lo_stage->reset( iv_path = ls_file-path iv_filename = ls_file-filename ).
|
||||
WHEN 'stage_ignore'.
|
||||
lo_stage->ignore( iv_path = ls_file-path iv_filename = ls_file-filename ).
|
||||
WHEN 'stage_rm'.
|
||||
lo_stage->rm( iv_path = ls_file-path iv_filename = ls_file-filename ).
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD. "stage_handle_action
|
||||
|
||||
ENDCLASS. " lcl_gui_router
|
|
@ -54,10 +54,6 @@ 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 repo_key_decode
|
||||
IMPORTING iv_string TYPE clike
|
||||
RETURNING VALUE(rv_key) TYPE lcl_persistence_repo=>ty_repo-key.
|
||||
|
||||
ENDCLASS. "lcl_html_action_utils DEFINITION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -261,23 +257,6 @@ CLASS lcl_html_action_utils IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "repo_key_encode
|
||||
|
||||
METHOD repo_key_decode.
|
||||
|
||||
DATA: lt_fields TYPE tihttpnvp,
|
||||
lv_string TYPE string.
|
||||
|
||||
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
|
||||
|
||||
lv_string = iv_string. " type conversion
|
||||
lt_fields = cl_http_utility=>if_http_utility~string_to_fields( lv_string ).
|
||||
|
||||
READ TABLE lt_fields ASSIGNING <ls_field> WITH KEY name = 'KEY'.
|
||||
IF sy-subrc = 0.
|
||||
rv_key = <ls_field>-value.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "repo_key_decode
|
||||
|
||||
ENDCLASS. "lcl_html_action_utils IMPLEMENTATION
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -428,6 +407,7 @@ ENDCLASS. "lcl_html_helper IMPLEMENTATION
|
|||
* CLASS lcl_html_toolbar DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_html_toolbar DEFINITION FINAL.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS add IMPORTING iv_txt TYPE string
|
||||
io_sub TYPE REF TO lcl_html_toolbar OPTIONAL
|
||||
|
@ -440,8 +420,6 @@ CLASS lcl_html_toolbar DEFINITION FINAL.
|
|||
iv_vertical TYPE abap_bool OPTIONAL
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS reset.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES: BEGIN OF ty_item,
|
||||
txt TYPE string,
|
||||
|
@ -461,10 +439,6 @@ ENDCLASS. "lcl_html_toolbar DEFINITION
|
|||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_html_toolbar IMPLEMENTATION.
|
||||
|
||||
METHOD reset.
|
||||
CLEAR mt_items.
|
||||
ENDMETHOD. "reset
|
||||
|
||||
METHOD add.
|
||||
DATA ls_item TYPE ty_item.
|
||||
|
||||
|
|
|
@ -30,8 +30,11 @@ CLASS lcl_gui_page_super DEFINITION ABSTRACT.
|
|||
|
||||
PROTECTED SECTION.
|
||||
METHODS render_repo_top
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo
|
||||
iv_show_package TYPE abap_bool DEFAULT abap_true
|
||||
iv_show_branch TYPE abap_bool DEFAULT abap_true
|
||||
iv_branch TYPE string OPTIONAL
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS header
|
||||
|
@ -81,13 +84,21 @@ CLASS lcl_gui_page_super IMPLEMENTATION.
|
|||
ro_html->add( '</td>' ).
|
||||
|
||||
ro_html->add( '<td class="repo_attr right">' ).
|
||||
ro_html->add( '<img src="img/pkg">' ).
|
||||
ro_html->add( |<span>{ io_repo->get_package( ) }</span>| ).
|
||||
IF iv_show_package = abap_true.
|
||||
ro_html->add( '<img src="img/pkg">' ).
|
||||
ro_html->add( |<span>{ io_repo->get_package( ) }</span>| ).
|
||||
ENDIF.
|
||||
|
||||
IF io_repo->is_offline( ) = abap_false.
|
||||
lo_repo_online ?= io_repo.
|
||||
ro_html->add( '<img src="img/branch">' ).
|
||||
ro_html->add( |<span>{ lo_repo_online->get_branch_name( ) }</span>| ).
|
||||
IF iv_show_branch = abap_true.
|
||||
ro_html->add( '<img src="img/branch">' ).
|
||||
IF iv_branch IS INITIAL.
|
||||
ro_html->add( |<span>{ lo_repo_online->get_branch_name( ) }</span>| ).
|
||||
ELSE.
|
||||
ro_html->add( |<span>{ iv_branch }</span>| ).
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
ro_html->add( '<img src="img/link">' ).
|
||||
ro_html->add( |<input type="text" value="{ lo_repo_online->get_url( ) }" readonly>| ).
|
||||
ENDIF.
|
||||
|
|
|
@ -195,7 +195,7 @@ CLASS lcl_branch_overview IMPLEMENTATION.
|
|||
|
||||
SPLIT ls_raw-body AT gc_newline INTO ls_commit-message lv_trash.
|
||||
|
||||
* todo, handle time zones
|
||||
* unix time stamps are in same time zone, so ignore the zone,
|
||||
FIND REGEX '^([\w\s]+) <(.*)> (\d{10}) .\d{4}$' IN ls_raw-author
|
||||
SUBMATCHES
|
||||
ls_commit-author
|
||||
|
@ -355,10 +355,7 @@ CLASS lcl_gui_page_branch_overview DEFINITION FINAL INHERITING FROM lcl_gui_page
|
|||
RETURNING VALUE(rv_string) TYPE string,
|
||||
escape_message
|
||||
IMPORTING iv_string TYPE string
|
||||
RETURNING VALUE(rv_string) TYPE string,
|
||||
get_script
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception.
|
||||
RETURNING VALUE(rv_string) TYPE string.
|
||||
|
||||
ENDCLASS. "lcl_gui_page_explore DEFINITION
|
||||
|
||||
|
@ -379,37 +376,6 @@ CLASS lcl_gui_page_branch_overview IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_script.
|
||||
|
||||
DATA: li_client TYPE REF TO if_http_client,
|
||||
lv_url TYPE string.
|
||||
|
||||
lv_url = 'https://raw.githubusercontent.com/bpatra/'
|
||||
&& 'gitgraph.js/develop/src/gitgraph.js' ##NO_TEXT.
|
||||
|
||||
cl_http_client=>create_by_url(
|
||||
EXPORTING
|
||||
url = lv_url
|
||||
ssl_id = 'ANONYM'
|
||||
IMPORTING
|
||||
client = li_client
|
||||
EXCEPTIONS
|
||||
argument_not_found = 1
|
||||
plugin_not_active = 2
|
||||
internal_error = 3
|
||||
OTHERS = 4 ).
|
||||
IF sy-subrc <> 0.
|
||||
_raise 'error fetching gitgraph.js script'.
|
||||
ENDIF.
|
||||
|
||||
li_client->send( ).
|
||||
li_client->receive( ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
ro_html->add( li_client->response->get_cdata( ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD form_select.
|
||||
|
||||
DATA: lv_name TYPE string,
|
||||
|
@ -436,7 +402,7 @@ CLASS lcl_gui_page_branch_overview IMPLEMENTATION.
|
|||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( '<form id="commit_form" method="post" action="sapevent:merge">' ).
|
||||
ro_html->add( 'Merge' ).
|
||||
ro_html->add( 'Merge' ) ##NO_TEXT.
|
||||
ro_html->add( form_select( 'source' ) ).
|
||||
ro_html->add( 'into' ).
|
||||
ro_html->add( form_select( 'target' ) ).
|
||||
|
@ -453,7 +419,10 @@ CLASS lcl_gui_page_branch_overview IMPLEMENTATION.
|
|||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( render_repo_top( mo_repo ) ).
|
||||
ro_html->add( render_repo_top(
|
||||
io_repo = mo_repo
|
||||
iv_show_package = abap_false
|
||||
iv_show_branch = abap_false ) ).
|
||||
ro_html->add( '<br>' ).
|
||||
ro_html->add( '<br>' ).
|
||||
|
||||
|
@ -462,14 +431,9 @@ CLASS lcl_gui_page_branch_overview IMPLEMENTATION.
|
|||
* see http://stackoverflow.com/questions/6081483/maximum-size-of-a-canvas-element
|
||||
_add '<canvas id="gitGraph"></canvas>'.
|
||||
|
||||
_add '<script type="text/javascript">'.
|
||||
* todo, temporary workaround
|
||||
* see https://github.com/nicoespeon/gitgraph.js/pull/88
|
||||
* and https://github.com/nicoespeon/gitgraph.js/issues/86
|
||||
* todo, use https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.2.2/gitgraph.min.js
|
||||
* when above issue is fixed
|
||||
ro_html->add( get_script( ) ).
|
||||
_add '</script>'.
|
||||
ro_html->add( '<script type="text/javascript" src="https://cdnjs.' &&
|
||||
'cloudflare.com/ajax/libs/gitgraph.js/1.2.3/gitgraph.min.js"></script>' ).
|
||||
|
||||
_add '<script type="text/javascript">'.
|
||||
_add 'var myTemplateConfig = {'.
|
||||
ro_html->add( 'colors: [ "#979797", "#008fb5", "#f1c109", "'
|
||||
|
|
|
@ -5,32 +5,34 @@
|
|||
CLASS lcl_gui_page_commit DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS constructor
|
||||
IMPORTING iv_repo_key TYPE lcl_persistence_repo=>ty_repo-key
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
METHODS:
|
||||
constructor
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
io_stage TYPE REF TO lcl_stage
|
||||
RAISING lcx_exception,
|
||||
lif_gui_page~render REDEFINITION,
|
||||
lif_gui_page~on_event REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: mo_repo TYPE REF TO lcl_repo_online,
|
||||
mo_stage TYPE REF TO lcl_stage.
|
||||
|
||||
METHODS render_menu
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS render_stage
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS render_form
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS scripts
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
METHODS:
|
||||
render_menu
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
render_stage
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception,
|
||||
render_form
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper
|
||||
RAISING lcx_exception,
|
||||
styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
scripts
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
commit_push
|
||||
IMPORTING it_postdata TYPE cnht_post_data_tab
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -39,8 +41,8 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
|||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
|
||||
mo_repo ?= lcl_app=>repo_srv( )->get( iv_repo_key ).
|
||||
mo_stage = lcl_app=>repo_srv( )->get_stage( iv_repo_key ).
|
||||
mo_repo = io_repo.
|
||||
mo_stage = io_stage.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD render_stage.
|
||||
|
@ -158,6 +160,18 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "render_menu
|
||||
|
||||
METHOD lif_gui_page~on_event.
|
||||
|
||||
CASE iv_action.
|
||||
WHEN 'commit_post'.
|
||||
commit_push( it_postdata ).
|
||||
ev_state = gc_event_state-go_back_to_bookmark.
|
||||
WHEN 'commit_cancel'.
|
||||
ev_state = gc_event_state-go_back.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
@ -166,7 +180,11 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
|||
ro_html->add( title( 'COMMIT' ) ).
|
||||
|
||||
ro_html->add( '<div class="repo">' ).
|
||||
ro_html->add( render_repo_top( mo_repo ) ).
|
||||
ro_html->add( render_repo_top(
|
||||
io_repo = mo_repo
|
||||
iv_show_package = abap_false
|
||||
iv_branch = mo_stage->get_branch_name( ) ) ).
|
||||
|
||||
ro_html->add( render_menu( ) ).
|
||||
ro_html->add( render_form( ) ).
|
||||
ro_html->add( render_stage( ) ).
|
||||
|
@ -217,6 +235,43 @@ CLASS lcl_gui_page_commit IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
METHOD commit_push.
|
||||
|
||||
DATA: ls_fields TYPE lcl_html_action_utils=>ty_commit_fields,
|
||||
ls_comment TYPE ty_comment,
|
||||
lo_user TYPE REF TO lcl_persistence_user.
|
||||
|
||||
|
||||
ls_fields = lcl_html_action_utils=>parse_commit_request( it_postdata ).
|
||||
|
||||
lo_user = lcl_app=>user( ).
|
||||
lo_user->set_username( ls_fields-username ).
|
||||
lo_user->set_email( ls_fields-email ).
|
||||
|
||||
IF ls_fields-username IS INITIAL.
|
||||
_raise 'empty username'.
|
||||
ELSEIF ls_fields-email IS INITIAL.
|
||||
_raise 'empty email'.
|
||||
ELSEIF ls_fields-comment IS INITIAL.
|
||||
_raise 'empty comment'.
|
||||
ENDIF.
|
||||
|
||||
ls_comment-username = ls_fields-username.
|
||||
ls_comment-email = ls_fields-email.
|
||||
ls_comment-comment = ls_fields-comment.
|
||||
|
||||
IF NOT ls_fields-body IS INITIAL.
|
||||
CONCATENATE ls_comment-comment gc_newline ls_fields-body
|
||||
INTO ls_comment-comment.
|
||||
ENDIF.
|
||||
|
||||
mo_repo->push( is_comment = ls_comment
|
||||
io_stage = mo_stage ).
|
||||
|
||||
COMMIT WORK.
|
||||
|
||||
ENDMETHOD. "commit_push
|
||||
|
||||
METHOD scripts.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
|
325
src/zabapgit_page_db.prog.abap
Normal file
325
src/zabapgit_page_db.prog.abap
Normal file
|
@ -0,0 +1,325 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_PAGE_DB
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_gui_page_db DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_display DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
METHODS: constructor
|
||||
IMPORTING is_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: ms_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_display IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
ms_key = is_key.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lv_data TYPE lcl_persistence_db=>ty_content-data_str.
|
||||
|
||||
TRY.
|
||||
lv_data = lcl_app=>db( )->read(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
CATCH lcx_not_found ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
|
||||
lv_data = lcl_xml_pretty=>print( lv_data ).
|
||||
|
||||
lv_data = escape( val = lv_data
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'CONFIG DISPLAY' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_entry">' ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Type:</td>| &&
|
||||
| <td>{ ms_key-type }</td></tr></table>| ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Value:</td>| &&
|
||||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
ro_html->add( |<pre>{ lv_data }</pre>| ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRY DISPLAY */'.
|
||||
_add 'div.db_entry {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
|
||||
_add 'div.db_entry pre {'.
|
||||
_add ' display: block;'.
|
||||
_add ' overflow: hidden;'.
|
||||
_add ' word-wrap:break-word;'.
|
||||
_add ' white-space: pre-wrap;'.
|
||||
_add ' background-color: #eaeaea;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add ' width: 50em;'.
|
||||
_add '}'.
|
||||
|
||||
_add 'table.tag {'.
|
||||
_add ' display: inline-block;'.
|
||||
_add ' border: 1px #b3c1cc solid;'.
|
||||
_add ' background-color: #eee;'.
|
||||
_add ' margin-right: 0.5em; '.
|
||||
_add '}'.
|
||||
_add 'table.tag td { padding: 0.2em 0.5em; }'.
|
||||
_add 'table.tag td.label { background-color: #b3c1cc; }'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_edit DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS lif_gui_page~render REDEFINITION.
|
||||
|
||||
METHODS: constructor
|
||||
IMPORTING is_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: ms_key TYPE lcl_persistence_db=>ty_content.
|
||||
|
||||
METHODS styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS scripts
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db_edit IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
ms_key = is_key.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lv_data TYPE lcl_persistence_db=>ty_content-data_str,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
TRY.
|
||||
lv_data = lcl_app=>db( )->read(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
CATCH lcx_not_found ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
|
||||
lcl_app=>db( )->lock(
|
||||
iv_type = ms_key-type
|
||||
iv_value = ms_key-value ).
|
||||
|
||||
lv_data = lcl_xml_pretty=>print( lv_data ).
|
||||
|
||||
lv_data = escape( val = lv_data
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'CONFIG EDIT' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_entry">' ).
|
||||
|
||||
" Banners
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Type:</td>| &&
|
||||
| <td>{ ms_key-type }</td></tr></table>| ).
|
||||
ro_html->add( |<table class="tag"><tr><td class="label">Value:</td>| &&
|
||||
| <td>{ ms_key-value }</td></tr></table>| ).
|
||||
|
||||
" Form
|
||||
ro_html->add( '<form id="db_form" method="post" action="sapevent:db_save">' ).
|
||||
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
|
||||
}</textarea>| ).
|
||||
ro_html->add( '</form>' ).
|
||||
|
||||
" Menu
|
||||
lo_toolbar->add( iv_act = 'submitDBForm();'
|
||||
iv_txt = 'Save'
|
||||
iv_typ = gc_action_type-onclick
|
||||
iv_opt = gc_html_opt-emphas ) ##NO_TEXT.
|
||||
|
||||
ro_html->add( '<div class="paddings">' ).
|
||||
ro_html->add( lo_toolbar->render( ) ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( '</div>' ). "db_entry
|
||||
|
||||
ro_html->add( footer( io_include_script = scripts( ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRY DISPLAY */'.
|
||||
_add 'div.db_entry {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
_add 'div.db_entry textarea { margin: 0.5em 0em; }'.
|
||||
_add 'table.tag {'.
|
||||
_add ' display: inline-block;'.
|
||||
_add ' border: 1px #b3c1cc solid;'.
|
||||
_add ' background-color: #eee;'.
|
||||
_add ' margin-right: 0.5em; '.
|
||||
_add '}'.
|
||||
_add 'table.tag td { padding: 0.2em 0.5em; }'.
|
||||
_add 'table.tag td.label { background-color: #b3c1cc; }'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
METHOD scripts.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add 'function submitDBForm() {'.
|
||||
_add ' document.getElementById("db_form").submit();'.
|
||||
_add '}'.
|
||||
|
||||
ENDMETHOD. "scripts
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_db IMPLEMENTATION.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
DATA: lt_data TYPE lcl_persistence_db=>tt_content,
|
||||
lv_escaped TYPE string,
|
||||
lv_action TYPE string,
|
||||
lv_trclass TYPE string,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
FIELD-SYMBOLS: <ls_data> LIKE LINE OF lt_data.
|
||||
|
||||
|
||||
lt_data = lcl_app=>db( )->list( ).
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'DATABASE PERSISTENCY' ) ).
|
||||
|
||||
ro_html->add( '<div class="db_list">' ).
|
||||
ro_html->add( '<table width="100%" class="db_tab">' ).
|
||||
|
||||
" Header
|
||||
ro_html->add( '<tr>' ).
|
||||
ro_html->add( '<th>Type</th>' ).
|
||||
ro_html->add( '<th>Value</th>' ).
|
||||
ro_html->add( '<th>Data</th>' ).
|
||||
ro_html->add( '<th></th>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
|
||||
" Lines
|
||||
LOOP AT lt_data ASSIGNING <ls_data>.
|
||||
CLEAR lv_trclass.
|
||||
IF sy-tabix = 1.
|
||||
lv_trclass = ' class="firstrow"' ##NO_TEXT.
|
||||
ENDIF.
|
||||
|
||||
IF strlen( <ls_data>-data_str ) >= 250.
|
||||
lv_escaped = escape( val = <ls_data>-data_str(250)
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
ELSE.
|
||||
lv_escaped = escape( val = <ls_data>-data_str
|
||||
format = cl_abap_format=>e_html_attr ).
|
||||
ENDIF.
|
||||
|
||||
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 }| ).
|
||||
|
||||
ro_html->add( |<tr{ lv_trclass }>| ).
|
||||
ro_html->add( |<td>{ <ls_data>-type }</td>| ).
|
||||
ro_html->add( |<td>{ <ls_data>-value }</td>| ).
|
||||
ro_html->add( |<td><pre>{ lv_escaped }</pre></td>| ).
|
||||
ro_html->add( '<td>' ).
|
||||
ro_html->add( lo_toolbar->render( iv_vertical = abap_true ) ).
|
||||
ro_html->add( '</td>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
ENDLOOP.
|
||||
|
||||
ro_html->add( '</table>' ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD. "lif_gui_page~render
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* DB ENTRIES */'.
|
||||
_add 'div.db_list {'.
|
||||
_add ' background-color: #f2f2f2;'.
|
||||
_add ' padding: 0.5em;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab pre {'.
|
||||
_add ' display: block;'.
|
||||
_add ' overflow: hidden;'.
|
||||
_add ' word-wrap:break-word;'.
|
||||
_add ' white-space: pre-wrap;'.
|
||||
_add ' background-color: #eaeaea;'.
|
||||
_add ' padding: 3px;'.
|
||||
_add ' width: 50em;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab tr.firstrow td { padding-top: 0.5em; }'.
|
||||
_add 'table.db_tab th {'.
|
||||
_add ' text-align: left;'.
|
||||
_add ' color: #888;'.
|
||||
_add ' padding: 0.2em;'.
|
||||
_add ' border-bottom: 1px #ddd solid;'.
|
||||
_add '}'.
|
||||
_add 'table.db_tab td {'.
|
||||
_add ' color: #333;'.
|
||||
_add ' padding: 0.2em;'.
|
||||
_add ' vertical-align: top;'.
|
||||
_add '}'.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
48
src/zabapgit_page_db.prog.xml
Normal file
48
src/zabapgit_page_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_PAGE_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_PAGE_DB</ENTRY>
|
||||
<LENGTH>24</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
|
@ -21,6 +21,7 @@ CLASS lcl_merge DEFINITION FINAL.
|
|||
ttree TYPE lcl_git_porcelain=>ty_expanded_tt,
|
||||
ctree TYPE lcl_git_porcelain=>ty_expanded_tt,
|
||||
result TYPE lcl_git_porcelain=>ty_expanded_tt,
|
||||
stage TYPE REF TO lcl_stage,
|
||||
END OF ty_merge.
|
||||
|
||||
CLASS-METHODS:
|
||||
|
@ -66,7 +67,9 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
lt_atarget TYPE ty_ancestor_tt.
|
||||
|
||||
|
||||
ASSERT NOT iv_source = iv_target.
|
||||
IF iv_source = iv_target.
|
||||
_raise 'source = target'.
|
||||
ENDIF.
|
||||
|
||||
CLEAR gs_merge.
|
||||
|
||||
|
@ -91,7 +94,6 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
it_objects = gt_objects
|
||||
iv_branch = gs_merge-common-commit ).
|
||||
|
||||
BREAK-POINT.
|
||||
calculate_result( ).
|
||||
|
||||
rs_merge = gs_merge.
|
||||
|
@ -110,6 +112,17 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
|
||||
METHOD calculate_result.
|
||||
|
||||
DEFINE _from_source.
|
||||
READ TABLE gt_objects ASSIGNING <ls_object>
|
||||
WITH KEY type = gc_type-blob
|
||||
sha1 = <ls_source>-sha1.
|
||||
ASSERT sy-subrc = 0.
|
||||
|
||||
gs_merge-stage->add( iv_path = <ls_file>-path
|
||||
iv_filename = <ls_file>-name
|
||||
iv_data = <ls_object>-data ).
|
||||
END-OF-DEFINITION.
|
||||
|
||||
DATA: lt_files TYPE lcl_git_porcelain=>ty_expanded_tt,
|
||||
lv_found_source TYPE abap_bool,
|
||||
lv_found_target TYPE abap_bool,
|
||||
|
@ -119,11 +132,18 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
<ls_target> LIKE LINE OF lt_files,
|
||||
<ls_common> LIKE LINE OF lt_files,
|
||||
<ls_file> LIKE LINE OF lt_files,
|
||||
<ls_result> LIKE LINE OF gs_merge-result.
|
||||
<ls_result> LIKE LINE OF gs_merge-result,
|
||||
<ls_object> LIKE LINE OF gt_objects.
|
||||
|
||||
|
||||
lt_files = all_files( ).
|
||||
|
||||
CREATE OBJECT gs_merge-stage
|
||||
EXPORTING
|
||||
iv_branch_name = gs_merge-target-name
|
||||
iv_branch_sha1 = gs_merge-target-sha1
|
||||
iv_merge_source = gs_merge-source-sha1.
|
||||
|
||||
LOOP AT lt_files ASSIGNING <ls_file>.
|
||||
|
||||
UNASSIGN <ls_source>.
|
||||
|
@ -149,6 +169,8 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
AND lv_found_common = abap_true
|
||||
AND <ls_target>-sha1 = <ls_common>-sha1.
|
||||
* deleted in source, skip
|
||||
gs_merge-stage->rm( iv_path = <ls_file>-path
|
||||
iv_filename = <ls_file>-name ).
|
||||
CONTINUE.
|
||||
ELSEIF lv_found_target = abap_false
|
||||
AND lv_found_common = abap_true
|
||||
|
@ -163,6 +185,7 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
|
||||
IF lv_found_target = abap_false.
|
||||
* added in source
|
||||
_from_source.
|
||||
<ls_result>-sha1 = <ls_source>-sha1.
|
||||
ELSEIF lv_found_source = abap_false.
|
||||
* added in target
|
||||
|
@ -184,6 +207,7 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
<ls_result>-sha1 = <ls_source>-sha1.
|
||||
ELSEIF <ls_target>-sha1 = <ls_common>-sha1.
|
||||
* changed in source
|
||||
_from_source.
|
||||
<ls_result>-sha1 = <ls_source>-sha1.
|
||||
ELSEIF <ls_source>-sha1 = <ls_common>-sha1.
|
||||
* changed in target
|
||||
|
@ -263,9 +287,11 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
METHOD fetch_git.
|
||||
|
||||
DEFINE _find.
|
||||
lv_name = 'refs/heads/' && &1.
|
||||
lv_name = 'refs/heads/' && &1 ##NO_TEXT.
|
||||
READ TABLE lt_branches INTO &2 WITH KEY name = lv_name.
|
||||
ASSERT sy-subrc = 0.
|
||||
IF sy-subrc <> 0.
|
||||
_raise 'branch not found'.
|
||||
ENDIF.
|
||||
APPEND &2 TO lt_upload.
|
||||
END-OF-DEFINITION.
|
||||
|
||||
|
@ -273,8 +299,6 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
lt_branches TYPE lcl_git_transport=>ty_branch_list_tt,
|
||||
lt_upload TYPE lcl_git_transport=>ty_branch_list_tt.
|
||||
|
||||
FIELD-SYMBOLS: <ls_branch> LIKE LINE OF lt_upload.
|
||||
|
||||
|
||||
lt_branches = lcl_git_transport=>branches( gs_merge-repo->get_url( ) ).
|
||||
|
||||
|
@ -286,8 +310,6 @@ CLASS lcl_merge IMPLEMENTATION.
|
|||
it_branches = lt_upload
|
||||
IMPORTING et_objects = gt_objects ).
|
||||
|
||||
DELETE gt_objects WHERE type = gc_type-blob.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
@ -310,6 +332,14 @@ CLASS lcl_gui_page_merge DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
|||
DATA: mo_repo TYPE REF TO lcl_repo_online,
|
||||
ms_merge TYPE lcl_merge=>ty_merge.
|
||||
|
||||
CONSTANTS: BEGIN OF c_actions,
|
||||
merge TYPE string VALUE 'merge' ##NO_TEXT,
|
||||
END OF c_actions.
|
||||
|
||||
METHODS:
|
||||
build_menu
|
||||
RETURNING VALUE(ro_menu) TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
ENDCLASS. "lcl_gui_page_merge DEFINITION
|
||||
|
||||
CLASS lcl_gui_page_merge IMPLEMENTATION.
|
||||
|
@ -328,7 +358,28 @@ CLASS lcl_gui_page_merge IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~on_event.
|
||||
BREAK-POINT.
|
||||
|
||||
CASE iv_action.
|
||||
WHEN c_actions-merge.
|
||||
IF ms_merge-stage->count( ) = 0.
|
||||
_raise 'nothing to merge'.
|
||||
ENDIF.
|
||||
|
||||
CREATE OBJECT ei_page TYPE lcl_gui_page_commit
|
||||
EXPORTING
|
||||
io_repo = mo_repo
|
||||
io_stage = ms_merge-stage.
|
||||
ev_state = gc_event_state-new_page.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD build_menu.
|
||||
|
||||
CREATE OBJECT ro_menu.
|
||||
|
||||
ro_menu->add( iv_txt = 'Merge' iv_act = c_actions-merge ) ##NO_TEXT.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
@ -361,9 +412,12 @@ CLASS lcl_gui_page_merge IMPLEMENTATION.
|
|||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( header( ) ).
|
||||
ro_html->add( title( 'MERGE' ) ).
|
||||
ro_html->add( title( iv_title = 'MERGE' io_menu = build_menu( ) ) ).
|
||||
ro_html->add( '<div id="toc">' ).
|
||||
ro_html->add( render_repo_top( mo_repo ) ).
|
||||
ro_html->add( render_repo_top(
|
||||
io_repo = mo_repo
|
||||
iv_show_package = abap_false
|
||||
iv_show_branch = abap_false ) ).
|
||||
|
||||
_add '<table>'.
|
||||
_add '<tr>'.
|
||||
|
@ -416,8 +470,6 @@ CLASS lcl_gui_page_merge IMPLEMENTATION.
|
|||
ENDLOOP.
|
||||
ro_html->add( '</table>' ).
|
||||
|
||||
ro_html->add( '<br>Todo' ).
|
||||
|
||||
ro_html->add( '</div>' ).
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
|
|
276
src/zabapgit_page_stage.prog.abap
Normal file
276
src/zabapgit_page_stage.prog.abap
Normal file
|
@ -0,0 +1,276 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_PAGE_STAGE
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_gui_page_stage DEFINITION FINAL INHERITING FROM lcl_gui_page_super.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS:
|
||||
constructor
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RAISING lcx_exception,
|
||||
lif_gui_page~render REDEFINITION,
|
||||
lif_gui_page~on_event REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: mo_repo TYPE REF TO lcl_repo_online,
|
||||
ms_files TYPE ty_stage_files,
|
||||
mo_stage TYPE REF TO lcl_stage.
|
||||
|
||||
METHODS:
|
||||
render_list
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
render_menu
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper,
|
||||
styles
|
||||
RETURNING VALUE(ro_html) TYPE REF TO lcl_html_helper.
|
||||
|
||||
METHODS stage_handle_action
|
||||
IMPORTING iv_getdata TYPE clike
|
||||
iv_action TYPE clike
|
||||
RAISING lcx_exception.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_gui_page_stage IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
super->constructor( ).
|
||||
mo_repo = io_repo.
|
||||
|
||||
ms_files = lcl_stage_logic=>get( mo_repo ).
|
||||
|
||||
CREATE OBJECT mo_stage
|
||||
EXPORTING
|
||||
iv_branch_name = io_repo->get_branch_name( )
|
||||
iv_branch_sha1 = io_repo->get_sha1_remote( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stage_handle_action.
|
||||
|
||||
DATA: ls_file TYPE ty_file.
|
||||
|
||||
FIELD-SYMBOLS: <ls_file> LIKE LINE OF ms_files-local.
|
||||
|
||||
|
||||
IF iv_action <> 'stage_all'.
|
||||
lcl_html_action_utils=>file_decode( EXPORTING iv_string = iv_getdata
|
||||
IMPORTING eg_file = ls_file ).
|
||||
ENDIF.
|
||||
|
||||
CASE iv_action.
|
||||
WHEN 'stage_add'.
|
||||
READ TABLE ms_files-local ASSIGNING <ls_file>
|
||||
WITH KEY file-path = ls_file-path
|
||||
file-filename = ls_file-filename.
|
||||
ASSERT sy-subrc = 0.
|
||||
mo_stage->add( iv_path = <ls_file>-file-path
|
||||
iv_filename = <ls_file>-file-filename
|
||||
iv_data = <ls_file>-file-data ).
|
||||
WHEN 'stage_all'.
|
||||
LOOP AT ms_files-local ASSIGNING <ls_file>.
|
||||
mo_stage->add( iv_path = <ls_file>-file-path
|
||||
iv_filename = <ls_file>-file-filename
|
||||
iv_data = <ls_file>-file-data ).
|
||||
ENDLOOP.
|
||||
WHEN 'stage_reset'.
|
||||
mo_stage->reset( iv_path = ls_file-path
|
||||
iv_filename = ls_file-filename ).
|
||||
WHEN 'stage_ignore'.
|
||||
mo_stage->ignore( iv_path = ls_file-path
|
||||
iv_filename = ls_file-filename ).
|
||||
WHEN 'stage_rm'.
|
||||
mo_stage->rm( iv_path = ls_file-path
|
||||
iv_filename = ls_file-filename ).
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD. "stage_handle_action
|
||||
|
||||
METHOD render_list.
|
||||
|
||||
DATA: lv_method TYPE lcl_stage=>ty_method,
|
||||
lv_param TYPE string,
|
||||
lv_status TYPE string,
|
||||
lo_toolbar TYPE REF TO lcl_html_toolbar.
|
||||
|
||||
FIELD-SYMBOLS: <ls_remote> LIKE LINE OF ms_files-remote,
|
||||
<ls_local> LIKE LINE OF ms_files-local.
|
||||
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( '<table class="stage_tab">' ).
|
||||
|
||||
LOOP AT ms_files-local ASSIGNING <ls_local>.
|
||||
IF sy-tabix = 1.
|
||||
ro_html->add('<tr class="separator firstrow">').
|
||||
ro_html->add( '<td></td><td colspan="2">LOCAL</td>' ).
|
||||
ro_html->add('</tr>').
|
||||
ENDIF.
|
||||
|
||||
lv_method = mo_stage->lookup( iv_path = <ls_local>-file-path
|
||||
iv_filename = <ls_local>-file-filename ).
|
||||
lv_param = lcl_html_action_utils=>file_encode( iv_key = mo_repo->get_key( )
|
||||
ig_file = <ls_local>-file ).
|
||||
|
||||
CREATE OBJECT lo_toolbar.
|
||||
IF lv_method IS NOT INITIAL.
|
||||
lo_toolbar->add( iv_txt = 'reset'
|
||||
iv_act = 'stage_reset?' && lv_param ) ##NO_TEXT.
|
||||
ELSE.
|
||||
lo_toolbar->add( iv_txt = 'add'
|
||||
iv_act = 'stage_add?' && lv_param ) ##NO_TEXT.
|
||||
ENDIF.
|
||||
|
||||
IF lv_method IS INITIAL.
|
||||
lv_status = '<span class="grey">?</span>'.
|
||||
ELSE.
|
||||
lv_status = lv_method.
|
||||
ENDIF.
|
||||
ro_html->add( '<tr>' ).
|
||||
ro_html->add( |<td class="status">{ lv_status }</td>| ).
|
||||
ro_html->add( |<td>{ <ls_local>-file-path && <ls_local>-file-filename }</td>| ).
|
||||
ro_html->add( '<td>' ).
|
||||
ro_html->add( lo_toolbar->render( iv_no_separator = abap_true ) ).
|
||||
ro_html->add( '</td>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT ms_files-remote ASSIGNING <ls_remote>.
|
||||
IF sy-tabix = 1.
|
||||
ro_html->add('<tr class="separator">').
|
||||
ro_html->add( '<td></td><td colspan="2">REMOTE</td>' ).
|
||||
ro_html->add('</tr>').
|
||||
ENDIF.
|
||||
|
||||
lv_method = mo_stage->lookup( iv_path = <ls_remote>-path
|
||||
iv_filename = <ls_remote>-filename ).
|
||||
lv_param = lcl_html_action_utils=>file_encode( iv_key = mo_repo->get_key( )
|
||||
ig_file = <ls_remote> ).
|
||||
|
||||
CREATE OBJECT lo_toolbar.
|
||||
IF lv_method IS NOT INITIAL.
|
||||
lo_toolbar->add( iv_txt = 'reset' iv_act = 'stage_reset?' && lv_param ) ##NO_TEXT.
|
||||
ELSE.
|
||||
lo_toolbar->add( iv_txt = 'ignore' iv_act = 'stage_ignore?' && lv_param ) ##NO_TEXT.
|
||||
lo_toolbar->add( iv_txt = 'remove' iv_act = 'stage_rm?' && lv_param ) ##NO_TEXT.
|
||||
ENDIF.
|
||||
|
||||
IF lv_method IS INITIAL.
|
||||
lv_status = '<span class="grey">?</span>'.
|
||||
ELSE.
|
||||
lv_status = lv_method.
|
||||
ENDIF.
|
||||
ro_html->add( '<tr>' ).
|
||||
ro_html->add( |<td class="status">{ lv_status }</td>| ).
|
||||
ro_html->add( |<td>{ <ls_remote>-path && <ls_remote>-filename }</td>| ).
|
||||
ro_html->add( '<td>' ).
|
||||
ro_html->add( lo_toolbar->render( iv_no_separator = abap_true ) ).
|
||||
ro_html->add( '</td>' ).
|
||||
ro_html->add( '</tr>' ).
|
||||
ENDLOOP.
|
||||
|
||||
ro_html->add( '</table>' ).
|
||||
|
||||
ENDMETHOD. "render_lines
|
||||
|
||||
METHOD lif_gui_page~on_event.
|
||||
|
||||
CASE iv_action.
|
||||
WHEN 'stage_all'
|
||||
OR 'stage_commit'.
|
||||
IF iv_action = 'stage_all'.
|
||||
stage_handle_action( iv_getdata = iv_getdata iv_action = iv_action ).
|
||||
ENDIF.
|
||||
CREATE OBJECT ei_page TYPE lcl_gui_page_commit
|
||||
EXPORTING
|
||||
io_repo = mo_repo
|
||||
io_stage = mo_stage.
|
||||
ev_state = gc_event_state-new_page.
|
||||
WHEN 'stage_add'
|
||||
OR 'stage_reset'
|
||||
OR 'stage_ignore'
|
||||
OR 'stage_rm'.
|
||||
stage_handle_action( iv_getdata = iv_getdata iv_action = iv_action ).
|
||||
ev_state = gc_event_state-re_render.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lif_gui_page~render.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
ro_html->add( header( io_include_style = styles( ) ) ).
|
||||
ro_html->add( title( 'STAGE' ) ).
|
||||
|
||||
ro_html->add( '<div class="repo">' ).
|
||||
ro_html->add( render_repo_top( mo_repo ) ).
|
||||
ro_html->add( render_menu( ) ).
|
||||
|
||||
ro_html->add( render_list( ) ).
|
||||
|
||||
ro_html->add( '</div>' ).
|
||||
ro_html->add( footer( ) ).
|
||||
|
||||
ENDMETHOD. "lif_gui_page~render
|
||||
|
||||
METHOD render_menu.
|
||||
|
||||
DATA: lo_toolbar TYPE REF TO lcl_html_toolbar,
|
||||
lv_action TYPE string.
|
||||
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
CREATE OBJECT lo_toolbar.
|
||||
|
||||
lv_action = lcl_html_action_utils=>repo_key_encode( mo_repo->get_key( ) ).
|
||||
|
||||
IF mo_stage->count( ) > 0.
|
||||
lo_toolbar->add( iv_act = |stage_commit?{ lv_action }|
|
||||
iv_txt = 'Commit'
|
||||
iv_opt = gc_html_opt-emphas ) ##NO_TEXT.
|
||||
ELSEIF lines( ms_files-local ) > 0.
|
||||
lo_toolbar->add( iv_act = |stage_all?{ lv_action }|
|
||||
iv_txt = 'Add all and commit') ##NO_TEXT.
|
||||
ENDIF.
|
||||
|
||||
ro_html->add( '<div class="paddings">' ).
|
||||
ro_html->add( lo_toolbar->render( ) ).
|
||||
ro_html->add( '</div>' ).
|
||||
|
||||
ENDMETHOD. "render_menu
|
||||
|
||||
METHOD styles.
|
||||
|
||||
CREATE OBJECT ro_html.
|
||||
|
||||
_add '/* STAGE */'.
|
||||
_add '.stage_tab {'.
|
||||
_add ' border: 1px solid #DDD;'.
|
||||
_add ' background: #fff;'.
|
||||
_add ' margin-top: 0.2em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab td {'.
|
||||
_add ' border-top: 1px solid #eee;'.
|
||||
_add ' color: #333;'.
|
||||
_add ' vertical-align: middle;'.
|
||||
_add ' padding: 2px 0.5em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab td.status {'.
|
||||
_add ' width: 2em;'.
|
||||
_add ' text-align: center;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab tr.separator td {'.
|
||||
_add ' color: #BBB;'.
|
||||
_add ' font-size: 10pt;'.
|
||||
_add ' background-color: #edf2f9;'.
|
||||
_add ' padding: 4px 0.5em;'.
|
||||
_add '}'.
|
||||
_add '.stage_tab tr.firstrow td { border-top: 0px; } '.
|
||||
|
||||
ENDMETHOD. "styles
|
||||
|
||||
ENDCLASS.
|
|
@ -3,7 +3,7 @@
|
|||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<PROGDIR>
|
||||
<NAME>ZABAPGIT_STAGE_IMPL</NAME>
|
||||
<NAME>ZABAPGIT_PAGE_STAGE</NAME>
|
||||
<STATE>A</STATE>
|
||||
<SQLX/>
|
||||
<EDTX/>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<item>
|
||||
<ID>R</ID>
|
||||
<KEY/>
|
||||
<ENTRY>Include ZABAPGIT_STAGE_IMPL</ENTRY>
|
||||
<ENTRY>Include ZABAPGIT_PAGE_STAGE</ENTRY>
|
||||
<LENGTH>27</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
|
@ -101,8 +101,8 @@ CLASS lcl_repo_online DEFINITION INHERITING FROM lcl_repo FINAL.
|
|||
RETURNING VALUE(rt_results) TYPE ty_results_tt
|
||||
RAISING lcx_exception,
|
||||
push
|
||||
IMPORTING is_comment TYPE ty_comment
|
||||
io_stage TYPE REF TO lcl_stage
|
||||
IMPORTING is_comment TYPE ty_comment
|
||||
io_stage TYPE REF TO lcl_stage
|
||||
RAISING lcx_exception.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
@ -179,27 +179,12 @@ CLASS lcl_repo_srv DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app.
|
|||
RETURNING VALUE(rv_installed) TYPE abap_bool
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS get_stage
|
||||
IMPORTING iv_repo_key TYPE lcl_persistence_db=>ty_value
|
||||
iv_new TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(ro_stage) TYPE REF TO lcl_stage
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS free_stage
|
||||
IMPORTING iv_repo_key TYPE lcl_persistence_db=>ty_value.
|
||||
|
||||
PRIVATE SECTION.
|
||||
|
||||
TYPES: BEGIN OF ty_stage_list,
|
||||
repo_key TYPE lcl_persistence_db=>ty_value,
|
||||
stage TYPE REF TO lcl_stage,
|
||||
END OF ty_stage_list.
|
||||
|
||||
METHODS constructor.
|
||||
|
||||
DATA: mv_init TYPE abap_bool VALUE abap_false,
|
||||
mo_persistence TYPE REF TO lcl_persistence_repo,
|
||||
mt_stages TYPE TABLE OF ty_stage_list,
|
||||
mt_list TYPE ty_repo_tt.
|
||||
|
||||
METHODS add
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
*& Include ZABAPGIT_REPO_IMPL
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_repo_offline IMPLEMENTATION
|
||||
*----------------------------------------------------------------------*
|
||||
|
@ -126,7 +125,6 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
|
||||
DATA: lv_branch TYPE ty_sha1.
|
||||
|
||||
ASSERT get_key( ) = io_stage->mv_repo_key.
|
||||
|
||||
handle_stage_ignore( io_stage ).
|
||||
|
||||
|
@ -134,21 +132,23 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
io_repo = me
|
||||
io_stage = io_stage ).
|
||||
|
||||
set( iv_sha1 = lv_branch ).
|
||||
IF io_stage->get_branch_sha1( ) = get_sha1_local( ).
|
||||
* pushing to the branch currently represented by this repository object
|
||||
set( iv_sha1 = lv_branch ).
|
||||
ENDIF.
|
||||
|
||||
refresh( ).
|
||||
|
||||
set( it_checksums = build_local_checksums( ) ).
|
||||
|
||||
ENDMETHOD. "push
|
||||
|
||||
METHOD handle_stage_ignore.
|
||||
|
||||
DATA: lt_stage TYPE lcl_stage=>ty_stage_tt.
|
||||
DATA: lv_add TYPE abap_bool,
|
||||
lt_stage TYPE lcl_stage=>ty_stage_tt.
|
||||
|
||||
FIELD-SYMBOLS: <ls_stage> LIKE LINE OF lt_stage.
|
||||
|
||||
ASSERT get_key( ) = io_stage->mv_repo_key.
|
||||
|
||||
lt_stage = io_stage->get_all( ).
|
||||
LOOP AT lt_stage ASSIGNING <ls_stage> WHERE method = lcl_stage=>c_method-ignore.
|
||||
|
@ -161,10 +161,17 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
io_stage->reset( iv_path = <ls_stage>-file-path
|
||||
iv_filename = <ls_stage>-file-filename ).
|
||||
|
||||
io_stage->update_and_add_dot_abapgit( mo_dot_abapgit->serialize( ) ).
|
||||
lv_add = abap_true.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
IF lv_add = abap_true.
|
||||
io_stage->add(
|
||||
iv_path = gc_root_dir
|
||||
iv_filename = gc_dot_abapgit
|
||||
iv_data = mo_dot_abapgit->serialize( ) ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS. "lcl_repo_online IMPLEMENTATION
|
||||
|
@ -607,34 +614,4 @@ CLASS lcl_repo_srv IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "is_repo_installed
|
||||
|
||||
METHOD get_stage.
|
||||
|
||||
DATA ls_stage LIKE LINE OF mt_stages.
|
||||
|
||||
IF iv_new = abap_true.
|
||||
|
||||
free_stage( iv_repo_key ). " Kill existing stage if any
|
||||
CREATE OBJECT ls_stage-stage EXPORTING iv_repo_key = iv_repo_key.
|
||||
ls_stage-repo_key = iv_repo_key.
|
||||
APPEND ls_stage TO mt_stages.
|
||||
|
||||
ELSE.
|
||||
|
||||
READ TABLE mt_stages INTO ls_stage WITH KEY repo_key = iv_repo_key.
|
||||
IF sy-subrc <> 0.
|
||||
_raise 'Existing stage not found'.
|
||||
ENDIF.
|
||||
|
||||
ENDIF.
|
||||
|
||||
ro_stage = ls_stage-stage.
|
||||
|
||||
ENDMETHOD. "get_stage
|
||||
|
||||
METHOD free_stage.
|
||||
|
||||
DELETE mt_stages WHERE repo_key = iv_repo_key. " Kill existing stage if any
|
||||
|
||||
ENDMETHOD. "free_stage
|
||||
|
||||
ENDCLASS. "lcl_repo_srv IMPLEMENTATION
|
|
@ -2,10 +2,8 @@
|
|||
*& Include ZABAPGIT_STAGE
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
*----------------------------------------------------------------------*
|
||||
* CLASS lcl_stage DEFINITION
|
||||
*----------------------------------------------------------------------*
|
||||
CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
||||
"! keep the list of staged files, independent of repository and branch
|
||||
CLASS lcl_stage DEFINITION FINAL.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES: ty_method TYPE c LENGTH 1.
|
||||
|
@ -16,11 +14,6 @@ CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
|||
ignore TYPE ty_method VALUE 'I',
|
||||
END OF c_method.
|
||||
|
||||
CONSTANTS: BEGIN OF c_wftype,
|
||||
local TYPE char1 VALUE 'L',
|
||||
remote TYPE char1 VALUE 'R',
|
||||
END OF c_wftype.
|
||||
|
||||
TYPES: BEGIN OF ty_stage,
|
||||
file TYPE ty_file,
|
||||
method TYPE ty_method,
|
||||
|
@ -29,32 +22,24 @@ CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
|||
TYPES: ty_stage_tt TYPE SORTED TABLE OF ty_stage
|
||||
WITH UNIQUE KEY file-path file-filename.
|
||||
|
||||
TYPES: BEGIN OF ty_work_file,
|
||||
type TYPE char1,
|
||||
file TYPE ty_file,
|
||||
END OF ty_work_file.
|
||||
|
||||
DATA mv_repo_key TYPE lcl_persistence_db=>ty_value READ-ONLY.
|
||||
DATA mv_local_cnt TYPE i READ-ONLY.
|
||||
DATA mt_workarea TYPE STANDARD TABLE OF ty_work_file READ-ONLY.
|
||||
|
||||
CLASS-METHODS method_description
|
||||
IMPORTING iv_method TYPE ty_method
|
||||
RETURNING VALUE(rv_description) TYPE string
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING iv_repo_key TYPE lcl_persistence_db=>ty_value
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS update_and_add_dot_abapgit
|
||||
IMPORTING iv_data TYPE ty_file-data
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS:
|
||||
constructor
|
||||
IMPORTING iv_branch_name TYPE string
|
||||
iv_branch_sha1 TYPE ty_sha1
|
||||
iv_merge_source TYPE ty_sha1 OPTIONAL,
|
||||
get_branch_name
|
||||
RETURNING VALUE(rv_branch) TYPE string,
|
||||
get_branch_sha1
|
||||
RETURNING VALUE(rv_branch) TYPE ty_sha1,
|
||||
add
|
||||
IMPORTING iv_path TYPE ty_file-path
|
||||
iv_filename TYPE ty_file-filename
|
||||
iv_data TYPE xstring
|
||||
RAISING lcx_exception,
|
||||
reset
|
||||
IMPORTING iv_path TYPE ty_file-path
|
||||
|
@ -72,24 +57,133 @@ CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
|||
IMPORTING iv_path TYPE ty_file-path
|
||||
iv_filename TYPE ty_file-filename
|
||||
RETURNING VALUE(rv_method) TYPE ty_method,
|
||||
get_merge_source
|
||||
RETURNING VALUE(rv_source) TYPE ty_sha1,
|
||||
count
|
||||
RETURNING VALUE(rv_count) TYPE i,
|
||||
get_all
|
||||
RETURNING VALUE(rt_stage) TYPE ty_stage_tt.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA: mt_stage TYPE ty_stage_tt.
|
||||
DATA: mt_stage TYPE ty_stage_tt,
|
||||
mv_branch_name TYPE string,
|
||||
mv_branch_sha1 TYPE ty_sha1,
|
||||
mv_merge_source TYPE ty_sha1.
|
||||
|
||||
METHODS append
|
||||
IMPORTING iv_path TYPE ty_file-path
|
||||
iv_filename TYPE ty_file-filename
|
||||
iv_method TYPE ty_method
|
||||
RAISING lcx_exception.
|
||||
METHODS:
|
||||
append
|
||||
IMPORTING iv_path TYPE ty_file-path
|
||||
iv_filename TYPE ty_file-filename
|
||||
iv_method TYPE ty_method
|
||||
iv_data TYPE xstring OPTIONAL
|
||||
RAISING lcx_exception.
|
||||
|
||||
METHODS find_work_file
|
||||
IMPORTING iv_path TYPE ty_file-path
|
||||
iv_filename TYPE ty_file-filename
|
||||
RETURNING VALUE(rs_file) TYPE ty_file
|
||||
RAISING lcx_exception.
|
||||
ENDCLASS. "lcl_stage DEFINITION
|
||||
|
||||
ENDCLASS. "lcl_stage DEFINITION
|
||||
CLASS lcl_stage IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
mv_branch_name = iv_branch_name.
|
||||
mv_branch_sha1 = iv_branch_sha1.
|
||||
mv_merge_source = iv_merge_source.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_branch_name.
|
||||
rv_branch = mv_branch_name.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_merge_source.
|
||||
rv_source = mv_merge_source.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_branch_sha1.
|
||||
rv_branch = mv_branch_sha1.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lookup.
|
||||
|
||||
DATA ls_stage LIKE LINE OF mt_stage.
|
||||
|
||||
|
||||
READ TABLE mt_stage INTO ls_stage
|
||||
WITH KEY file-path = iv_path
|
||||
file-filename = iv_filename.
|
||||
IF sy-subrc = 0.
|
||||
rv_method = ls_stage-method.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "lookup
|
||||
|
||||
METHOD get_all.
|
||||
rt_stage = mt_stage.
|
||||
ENDMETHOD. "get_all
|
||||
|
||||
METHOD append.
|
||||
|
||||
DATA: ls_stage LIKE LINE OF mt_stage.
|
||||
|
||||
FIELD-SYMBOLS: <ls_stage> LIKE LINE OF mt_stage.
|
||||
|
||||
|
||||
READ TABLE mt_stage WITH KEY
|
||||
file-path = iv_path
|
||||
file-filename = iv_filename
|
||||
ASSIGNING <ls_stage>.
|
||||
IF sy-subrc = 0.
|
||||
<ls_stage>-file-data = iv_data.
|
||||
<ls_stage>-method = iv_method.
|
||||
ELSE.
|
||||
ls_stage-file-path = iv_path.
|
||||
ls_stage-file-filename = iv_filename.
|
||||
ls_stage-file-data = iv_data.
|
||||
ls_stage-method = iv_method.
|
||||
INSERT ls_stage INTO TABLE mt_stage.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "append
|
||||
|
||||
METHOD method_description.
|
||||
|
||||
CASE iv_method.
|
||||
WHEN c_method-add.
|
||||
rv_description = 'add'.
|
||||
WHEN c_method-rm.
|
||||
rv_description = 'rm'.
|
||||
WHEN c_method-ignore.
|
||||
rv_description = 'ignore' ##NO_TEXT.
|
||||
WHEN OTHERS.
|
||||
_raise 'unknown staging method type'.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD. "method_description
|
||||
|
||||
METHOD add.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-add
|
||||
iv_data = iv_data ).
|
||||
ENDMETHOD. "add
|
||||
|
||||
METHOD reset.
|
||||
DELETE mt_stage WHERE file-path = iv_path
|
||||
AND file-filename = iv_filename.
|
||||
ASSERT sy-subrc = 0.
|
||||
ENDMETHOD. "reset
|
||||
|
||||
METHOD rm.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-rm ).
|
||||
ENDMETHOD. "rm
|
||||
|
||||
METHOD ignore.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-ignore ).
|
||||
ENDMETHOD. "ignore
|
||||
|
||||
METHOD count.
|
||||
rv_count = lines( mt_stage ).
|
||||
ENDMETHOD. "count
|
||||
|
||||
ENDCLASS.
|
|
@ -1,246 +0,0 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_STAGE_IMPL
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
CLASS lcl_stage_logic DEFINITION FINAL.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_stage_files,
|
||||
local TYPE ty_files_item_tt,
|
||||
remote TYPE ty_files_tt,
|
||||
END OF ty_stage_files.
|
||||
|
||||
CLASS-METHODS:
|
||||
get
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RETURNING VALUE(rs_files) TYPE ty_stage_files
|
||||
RAISING lcx_exception,
|
||||
count
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RETURNING VALUE(rv_count) TYPE i
|
||||
RAISING lcx_exception.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CLASS-METHODS:
|
||||
remove_ignored
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
CHANGING cs_files TYPE ty_stage_files,
|
||||
remove_identical
|
||||
CHANGING cs_files TYPE ty_stage_files.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_stage_logic IMPLEMENTATION.
|
||||
|
||||
METHOD get.
|
||||
rs_files-local = io_repo->get_files_local( ).
|
||||
rs_files-remote = io_repo->get_files_remote( ).
|
||||
remove_identical( CHANGING cs_files = rs_files ).
|
||||
remove_ignored( EXPORTING io_repo = io_repo
|
||||
CHANGING cs_files = rs_files ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD count.
|
||||
|
||||
DATA: ls_files TYPE ty_stage_files.
|
||||
|
||||
ls_files = get( io_repo ).
|
||||
|
||||
rv_count = lines( ls_files-remote ) + lines( ls_files-local ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_ignored.
|
||||
|
||||
DATA: lv_index TYPE i.
|
||||
|
||||
FIELD-SYMBOLS: <ls_remote> LIKE LINE OF cs_files-remote.
|
||||
|
||||
|
||||
LOOP AT cs_files-remote ASSIGNING <ls_remote>.
|
||||
lv_index = sy-tabix.
|
||||
|
||||
IF io_repo->get_dot_abapgit( )->is_ignored(
|
||||
iv_path = <ls_remote>-path
|
||||
iv_filename = <ls_remote>-filename ) = abap_true.
|
||||
DELETE cs_files-remote INDEX lv_index.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_identical.
|
||||
|
||||
DATA: lv_index TYPE i,
|
||||
ls_remote LIKE LINE OF cs_files-remote.
|
||||
|
||||
FIELD-SYMBOLS: <ls_local> LIKE LINE OF cs_files-local.
|
||||
|
||||
|
||||
LOOP AT cs_files-local ASSIGNING <ls_local>.
|
||||
lv_index = sy-tabix.
|
||||
|
||||
READ TABLE cs_files-remote INTO ls_remote
|
||||
WITH KEY path = <ls_local>-file-path
|
||||
filename = <ls_local>-file-filename.
|
||||
IF sy-subrc = 0.
|
||||
DELETE cs_files-remote INDEX sy-tabix.
|
||||
IF ls_remote-data = <ls_local>-file-data.
|
||||
DELETE cs_files-local INDEX lv_index.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_stage IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
DATA: ls_files TYPE lcl_stage_logic=>ty_stage_files,
|
||||
lo_repo TYPE REF TO lcl_repo_online,
|
||||
ls_work_file LIKE LINE OF mt_workarea.
|
||||
|
||||
FIELD-SYMBOLS: <ls_local> LIKE LINE OF ls_files-local,
|
||||
<ls_remote> LIKE LINE OF ls_files-remote.
|
||||
|
||||
mv_repo_key = iv_repo_key.
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_repo_key ).
|
||||
ls_files = lcl_stage_logic=>get( lo_repo ).
|
||||
|
||||
" Unify structures
|
||||
LOOP AT ls_files-local ASSIGNING <ls_local>.
|
||||
ls_work_file-type = c_wftype-local.
|
||||
ls_work_file-file = <ls_local>-file.
|
||||
APPEND ls_work_file TO mt_workarea.
|
||||
mv_local_cnt = mv_local_cnt + 1.
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT ls_files-remote ASSIGNING <ls_remote>.
|
||||
ls_work_file-type = c_wftype-remote.
|
||||
ls_work_file-file = <ls_remote>.
|
||||
APPEND ls_work_file TO mt_workarea.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD. "constructor
|
||||
|
||||
METHOD lookup.
|
||||
DATA ls_stage LIKE LINE OF mt_stage.
|
||||
|
||||
READ TABLE mt_stage INTO ls_stage
|
||||
WITH KEY file-path = iv_path
|
||||
file-filename = iv_filename.
|
||||
IF sy-subrc = 0.
|
||||
rv_method = ls_stage-method.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "lookup
|
||||
|
||||
METHOD get_all.
|
||||
rt_stage = mt_stage.
|
||||
ENDMETHOD. "get_all
|
||||
|
||||
METHOD append.
|
||||
|
||||
DATA: ls_stage LIKE LINE OF mt_stage,
|
||||
ls_file TYPE ty_file.
|
||||
|
||||
FIELD-SYMBOLS: <ls_stage> LIKE LINE OF mt_stage.
|
||||
|
||||
ls_file = find_work_file( iv_path = iv_path iv_filename = iv_filename ).
|
||||
|
||||
READ TABLE mt_stage WITH KEY
|
||||
file-path = ls_file-path
|
||||
file-filename = ls_file-filename
|
||||
ASSIGNING <ls_stage>.
|
||||
IF sy-subrc = 0.
|
||||
<ls_stage>-file-data = ls_file-data.
|
||||
<ls_stage>-method = iv_method.
|
||||
ELSE.
|
||||
ls_stage-file = ls_file.
|
||||
ls_stage-method = iv_method.
|
||||
INSERT ls_stage INTO TABLE mt_stage.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "append
|
||||
|
||||
METHOD method_description.
|
||||
|
||||
CASE iv_method.
|
||||
WHEN c_method-add.
|
||||
rv_description = 'add'.
|
||||
WHEN c_method-rm.
|
||||
rv_description = 'rm'.
|
||||
WHEN c_method-ignore.
|
||||
rv_description = 'ignore' ##NO_TEXT.
|
||||
WHEN OTHERS.
|
||||
_raise 'unknown staging method type'.
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD. "method_description
|
||||
|
||||
METHOD add.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-add ).
|
||||
ENDMETHOD. "add
|
||||
|
||||
METHOD reset.
|
||||
DELETE mt_stage WHERE file-path = iv_path
|
||||
AND file-filename = iv_filename.
|
||||
ASSERT sy-subrc = 0.
|
||||
ENDMETHOD. "reset
|
||||
|
||||
METHOD rm.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-rm ).
|
||||
ENDMETHOD. "rm
|
||||
|
||||
METHOD ignore.
|
||||
append( iv_path = iv_path
|
||||
iv_filename = iv_filename
|
||||
iv_method = c_method-ignore ).
|
||||
ENDMETHOD. "ignore
|
||||
|
||||
METHOD count.
|
||||
rv_count = lines( mt_stage ).
|
||||
ENDMETHOD. "count
|
||||
|
||||
METHOD find_work_file.
|
||||
DATA ls_work_file LIKE LINE OF mt_workarea.
|
||||
|
||||
READ TABLE mt_workarea INTO ls_work_file
|
||||
WITH KEY file-path = iv_path
|
||||
file-filename = iv_filename.
|
||||
IF sy-subrc = 0.
|
||||
rs_file = ls_work_file-file.
|
||||
ELSE.
|
||||
_raise 'File not found in workarea'.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD. "check_work_file_exists
|
||||
|
||||
METHOD update_and_add_dot_abapgit.
|
||||
|
||||
FIELD-SYMBOLS <ls_dot_abapgit> LIKE LINE OF mt_workarea.
|
||||
|
||||
READ TABLE mt_workarea ASSIGNING <ls_dot_abapgit>
|
||||
WITH KEY file-path = gc_root_dir
|
||||
file-filename = gc_dot_abapgit.
|
||||
IF sy-subrc <> 0.
|
||||
APPEND INITIAL LINE TO mt_workarea ASSIGNING <ls_dot_abapgit>.
|
||||
<ls_dot_abapgit>-type = c_wftype-local.
|
||||
<ls_dot_abapgit>-file-path = gc_root_dir.
|
||||
<ls_dot_abapgit>-file-filename = gc_dot_abapgit.
|
||||
ENDIF.
|
||||
|
||||
<ls_dot_abapgit>-file-data = iv_data.
|
||||
|
||||
add( iv_path = gc_root_dir
|
||||
iv_filename = gc_dot_abapgit ).
|
||||
|
||||
ENDMETHOD. "update_and_add_dot_abapgit
|
||||
|
||||
ENDCLASS.
|
93
src/zabapgit_stage_logic.prog.abap
Normal file
93
src/zabapgit_stage_logic.prog.abap
Normal file
|
@ -0,0 +1,93 @@
|
|||
*&---------------------------------------------------------------------*
|
||||
*& Include ZABAPGIT_STAGE_LOGIC
|
||||
*&---------------------------------------------------------------------*
|
||||
|
||||
"! Class is used to compare the files on remote local
|
||||
"! ie. list possible files to stage
|
||||
CLASS lcl_stage_logic DEFINITION FINAL.
|
||||
|
||||
PUBLIC SECTION.
|
||||
CLASS-METHODS:
|
||||
get
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RETURNING VALUE(rs_files) TYPE ty_stage_files
|
||||
RAISING lcx_exception,
|
||||
count
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
RETURNING VALUE(rv_count) TYPE i
|
||||
RAISING lcx_exception.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CLASS-METHODS:
|
||||
remove_ignored
|
||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
||||
CHANGING cs_files TYPE ty_stage_files,
|
||||
remove_identical
|
||||
CHANGING cs_files TYPE ty_stage_files.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
CLASS lcl_stage_logic IMPLEMENTATION.
|
||||
|
||||
METHOD get.
|
||||
rs_files-local = io_repo->get_files_local( ).
|
||||
rs_files-remote = io_repo->get_files_remote( ).
|
||||
remove_identical( CHANGING cs_files = rs_files ).
|
||||
remove_ignored( EXPORTING io_repo = io_repo
|
||||
CHANGING cs_files = rs_files ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD count.
|
||||
|
||||
DATA: ls_files TYPE ty_stage_files.
|
||||
|
||||
ls_files = get( io_repo ).
|
||||
|
||||
rv_count = lines( ls_files-remote ) + lines( ls_files-local ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_ignored.
|
||||
|
||||
DATA: lv_index TYPE i.
|
||||
|
||||
FIELD-SYMBOLS: <ls_remote> LIKE LINE OF cs_files-remote.
|
||||
|
||||
|
||||
LOOP AT cs_files-remote ASSIGNING <ls_remote>.
|
||||
lv_index = sy-tabix.
|
||||
|
||||
IF io_repo->get_dot_abapgit( )->is_ignored(
|
||||
iv_path = <ls_remote>-path
|
||||
iv_filename = <ls_remote>-filename ) = abap_true.
|
||||
DELETE cs_files-remote INDEX lv_index.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_identical.
|
||||
|
||||
DATA: lv_index TYPE i,
|
||||
ls_remote LIKE LINE OF cs_files-remote.
|
||||
|
||||
FIELD-SYMBOLS: <ls_local> LIKE LINE OF cs_files-local.
|
||||
|
||||
|
||||
LOOP AT cs_files-local ASSIGNING <ls_local>.
|
||||
lv_index = sy-tabix.
|
||||
|
||||
READ TABLE cs_files-remote INTO ls_remote
|
||||
WITH KEY path = <ls_local>-file-path
|
||||
filename = <ls_local>-file-filename.
|
||||
IF sy-subrc = 0.
|
||||
DELETE cs_files-remote INDEX sy-tabix.
|
||||
IF ls_remote-data = <ls_local>-file-data.
|
||||
DELETE cs_files-local INDEX lv_index.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
48
src/zabapgit_stage_logic.prog.xml
Normal file
48
src/zabapgit_stage_logic.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_STAGE_LOGIC</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_STAGE_LOGIC</ENTRY>
|
||||
<LENGTH>28</LENGTH>
|
||||
<SPLIT/>
|
||||
</item>
|
||||
</TPOOL>
|
||||
</asx:values>
|
||||
</asx:abap>
|
||||
</abapGit>
|
Loading…
Reference in New Issue
Block a user