Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #19

Merged
merged 5 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cloud/zcl_abapgit_abap_language_vers.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ CLASS lcl_environment IMPLEMENTATION.
ENDMETHOD.
METHOD zif_abapgit_environment~is_variant_maintenance.
ENDMETHOD.
METHOD zif_abapgit_environment~init_parallel_processing.
ENDMETHOD.

ENDCLASS.

Expand Down
4 changes: 4 additions & 0 deletions cloud/zcl_abapgit_environment.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ CLASS zcl_abapgit_environment IMPLEMENTATION.
ASSERT 1 = 'decoupled'.
ENDMETHOD.

METHOD zif_abapgit_environment~init_parallel_processing.
ASSERT 1 = 'decoupled'.
ENDMETHOD.

METHOD zif_abapgit_environment~get_basis_release.
ASSERT 1 = 'decoupled'.
ENDMETHOD.
Expand Down
39 changes: 34 additions & 5 deletions cloud/zcl_abapgit_exit.clas.abap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CLASS zcl_abapgit_exit DEFINITION
PUBLIC
CREATE PUBLIC.
CREATE PUBLIC
GLOBAL FRIENDS zcl_abapgit_injector.

PUBLIC SECTION.

Expand All @@ -16,6 +17,10 @@ CLASS zcl_abapgit_exit DEFINITION
CLASS-DATA gi_global_exit TYPE REF TO zif_abapgit_exit.
CLASS-DATA gi_exit TYPE REF TO zif_abapgit_exit.

CLASS-METHODS is_running_in_test_context
RETURNING
VALUE(rv_running_in_test_context) TYPE abap_bool.

ENDCLASS.


Expand All @@ -39,17 +44,41 @@ CLASS zcl_abapgit_exit IMPLEMENTATION.
lv_class_name = |\\PROGRAM={ sy-repid }\\CLASS={ lv_class_name }|.
ENDIF.

TRY.
CREATE OBJECT gi_exit TYPE (lv_class_name).
CATCH cx_sy_create_object_error ##NO_HANDLER.
ENDTRY.
" Prevent non-mocked exit calls in unit tests
IF is_running_in_test_context( ) = abap_false.
TRY.
CREATE OBJECT gi_exit TYPE (lv_class_name).
CATCH cx_sy_create_object_error ##NO_HANDLER.
ENDTRY.
ENDIF.

CREATE OBJECT gi_global_exit TYPE zcl_abapgit_exit. " this class

ri_exit = gi_global_exit.

ENDMETHOD.

METHOD is_running_in_test_context.

IF sy-sysid = 'ABC'.
" always run on open-abap
rv_running_in_test_context = abap_true.
RETURN.
ENDIF.

" Check if the local test class can be accessed by RTTI. If so the current process is running in a unit test.
" Note this approach only works for the developer version. The standalone version will always report not running in
" test context which should be fine as there are no unit tests delivered in it.
cl_abap_typedescr=>describe_by_name(
EXPORTING
p_name = |\\PROGRAM={ sy-repid }\\CLASS=LTCL_TEST|
EXCEPTIONS
type_not_found = 1
OTHERS = 2 ).
rv_running_in_test_context = boolc( sy-subrc = 0 ).

ENDMETHOD.


METHOD zif_abapgit_exit~adjust_display_commit_url.

Expand Down
20 changes: 20 additions & 0 deletions cloud/zcl_abapgit_exit.clas.testclasses.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
*"* use this source file for your ABAP unit test classes

CLASS ltcl_test DEFINITION DEFERRED.
CLASS zcl_abapgit_exit DEFINITION LOCAL FRIENDS ltcl_test.

" The class name ltcl_test is hardcoded in zcl_abapgit_exit=>is_running_in_test_context

CLASS ltcl_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
PRIVATE SECTION.
METHODS:
is_running_in_test_context FOR TESTING.
ENDCLASS.

CLASS ltcl_test IMPLEMENTATION.
METHOD is_running_in_test_context.
cl_abap_unit_assert=>assert_equals(
act = zcl_abapgit_exit=>is_running_in_test_context( )
exp = abap_true ).
ENDMETHOD.
ENDCLASS.
1 change: 1 addition & 0 deletions cloud/zcl_abapgit_exit.clas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
</VSEOCLASS>
</asx:values>
</asx:abap>
Expand Down
5 changes: 3 additions & 2 deletions cloud/zcl_abapgit_folder_logic.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,19 @@ CLASS zcl_abapgit_folder_logic IMPLEMENTATION.

DATA: lv_length TYPE i,
lv_parent TYPE I_CustABAPObjDirectoryEntry-ABAPPackage,
ls_package TYPE scompkdtln,
ls_package TYPE zif_abapgit_sap_package=>ty_create,
lv_new TYPE string,
lv_path TYPE string,
lv_absolute_name TYPE string,
lv_folder_logic TYPE string,
lt_unique_package_names TYPE HASHED TABLE OF I_CustABAPObjDirectoryEntry-ABAPPackage WITH UNIQUE KEY table_line.

lv_length = strlen( io_dot->get_starting_folder( ) ).
lv_length = strlen( io_dot->get_starting_folder( ) ).
IF lv_length > strlen( iv_path ).
* treat as not existing locally
RETURN.
ENDIF.

lv_path = iv_path+lv_length.
lv_parent = iv_top.
rv_package = iv_top.
Expand Down
16 changes: 0 additions & 16 deletions cloud/zcl_abapgit_folder_logic.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ CLASS ltcl_folder_logic_package IMPLEMENTATION.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~get_transport_layer.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~create.
RETURN.
ENDMETHOD.
Expand Down Expand Up @@ -199,10 +195,6 @@ CLASS ltcl_folder_logic IMPLEMENTATION.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~get_transport_layer.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~create.
RETURN.
ENDMETHOD.
Expand Down Expand Up @@ -417,10 +409,6 @@ CLASS ltcl_folder_logic_namespaces IMPLEMENTATION.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~get_transport_layer.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~create.
RETURN.
ENDMETHOD.
Expand Down Expand Up @@ -560,10 +548,6 @@ CLASS ltcl_folder_logic_no_parent IMPLEMENTATION.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~get_transport_layer.
RETURN.
ENDMETHOD.

METHOD zif_abapgit_sap_package~create.
RETURN.
ENDMETHOD.
Expand Down
2 changes: 1 addition & 1 deletion cloud/zcl_abapgit_gui_page_db.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ CLASS zcl_abapgit_gui_page_db IMPLEMENTATION.

lv_zip = lo_zip->save( ).

CONCATENATE 'abapGit_Backup_' sy-datlo '_' sy-timlo INTO lv_filename.
CONCATENATE 'abapGit_Backup_' sy-datlo '_' sy-timlo '.zip' INTO lv_filename.

li_fe_serv = zcl_abapgit_ui_factory=>get_frontend_services( ).

Expand Down
46 changes: 34 additions & 12 deletions cloud/zcl_abapgit_gui_page_flow.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_FLOW IMPLEMENTATION.
METHOD render_table.

DATA ls_path_name LIKE LINE OF is_feature-changed_files.
DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar.
DATA lv_status TYPE string.
DATA lv_branch TYPE string.
DATA lv_param TYPE string.
Expand All @@ -100,8 +101,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_FLOW IMPLEMENTATION.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.

ri_html->add( |<table>| ).
ri_html->add( |<tr><td><u>Filename</u></td><td><u>Remote SHA1</u></td>| &&
|<td><u>Local SHA1</u></td><td></td></tr>| ).
ri_html->add( |<tr><td><u>Filename</u></td><td><u>Remote</u></td><td><u>Local</u></td><td></td></tr>| ).

lv_branch = is_feature-branch-display_name.
IF lv_branch IS INITIAL.
Expand Down Expand Up @@ -129,13 +129,15 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_FLOW IMPLEMENTATION.
ri_html->add( |</table>| ).

* todo: crossout if write protected
ri_html->add( ri_html->a(
iv_txt = 'Pull'
iv_act = |{ c_action-pull }?index={ iv_index }&key={ is_feature-repo-key }| ) ).
ri_html->add( ri_html->a(
iv_txt = 'Stage'
iv_act = |{ c_action-stage }?index={ iv_index }&key={ is_feature-repo-key }&branch={ lv_branch }| ) ).
ri_html->add( |<br>| ).

CREATE OBJECT lo_toolbar EXPORTING iv_id = 'toolbar-flow'.
lo_toolbar->add( iv_txt = 'Pull'
iv_act = |{ c_action-pull }?index={ iv_index }&key={ is_feature-repo-key }&branch={ lv_branch }|
iv_opt = zif_abapgit_html=>c_html_opt-strong ).
lo_toolbar->add( iv_txt = 'Stage'
iv_act = |{ c_action-stage }?index={ iv_index }&key={ is_feature-repo-key }&branch={ lv_branch }|
iv_opt = zif_abapgit_html=>c_html_opt-strong ).
ri_html->add( lo_toolbar->render( ) ).

ENDMETHOD.

Expand Down Expand Up @@ -205,17 +207,37 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_FLOW IMPLEMENTATION.
io_repo = lo_online
ii_obj_filter = lo_filter ).

rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.
rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark.

refresh( ).
WHEN c_action-pull.
lv_key = ii_event->query( )->get( 'KEY' ).
lv_index = ii_event->query( )->get( 'INDEX' ).
lv_branch = ii_event->query( )->get( 'BRANCH' ).
lo_online ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).

READ TABLE mt_features INTO ls_feature INDEX lv_index.
ASSERT sy-subrc = 0.

* todo: set filter,
zcl_abapgit_services_repo=>gui_deserialize( lo_online ).
LOOP AT ls_feature-changed_objects ASSIGNING <ls_object>.
APPEND INITIAL LINE TO lt_filter ASSIGNING <ls_filter>.
<ls_filter>-object = <ls_object>-obj_type.
<ls_filter>-obj_name = <ls_object>-obj_name.
ENDLOOP.
CREATE OBJECT lo_filter EXPORTING it_filter = lt_filter.

set_branch(
iv_branch = lv_branch
iv_key = lv_key ).

rs_handled-page = zcl_abapgit_gui_page_pull=>create(
io_repo = lo_online
iv_trkorr = ls_feature-transport-trkorr
ii_obj_filter = lo_filter ).

rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.

refresh( ).
ENDCASE.

ENDMETHOD.
Expand Down
Loading