mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
done, everything moved from top, close #210
split is not perfect, but will do for now, we can split into more includes in the future
This commit is contained in:
parent
7ea64a5cf7
commit
9cf235cb3f
|
@ -3,7 +3,7 @@ REPORT zabapgit LINE-SIZE 100.
|
||||||
* See http://www.abapgit.org
|
* See http://www.abapgit.org
|
||||||
|
|
||||||
CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT
|
CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT
|
||||||
gc_abap_version TYPE string VALUE 'v1.12.6'. "#EC NOTEXT
|
gc_abap_version TYPE string VALUE 'v1.12.7'. "#EC NOTEXT
|
||||||
|
|
||||||
********************************************************************************
|
********************************************************************************
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
|
@ -29,286 +29,28 @@ CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
********************************************************************************
|
********************************************************************************
|
||||||
|
|
||||||
TYPE-POOLS seop.
|
|
||||||
|
|
||||||
TYPES: ty_type TYPE c LENGTH 6,
|
|
||||||
ty_bitbyte TYPE c LENGTH 8,
|
|
||||||
ty_sha1 TYPE c LENGTH 40.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_file,
|
|
||||||
path TYPE string,
|
|
||||||
filename TYPE string,
|
|
||||||
data TYPE xstring,
|
|
||||||
END OF ty_file.
|
|
||||||
TYPES: ty_files_tt TYPE STANDARD TABLE OF ty_file WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: ty_string_tt TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
|
|
||||||
TYPES: tt_w3urls TYPE STANDARD TABLE OF w3url WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_comment,
|
|
||||||
username TYPE string,
|
|
||||||
email TYPE string,
|
|
||||||
comment TYPE string,
|
|
||||||
END OF ty_comment.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_item,
|
|
||||||
obj_type TYPE tadir-object,
|
|
||||||
obj_name TYPE tadir-obj_name,
|
|
||||||
END OF ty_item.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_file_item,
|
|
||||||
file TYPE ty_file,
|
|
||||||
item TYPE ty_item,
|
|
||||||
END OF ty_file_item.
|
|
||||||
TYPES: ty_files_item_tt TYPE STANDARD TABLE OF ty_file_item WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_metadata,
|
|
||||||
class TYPE string,
|
|
||||||
version TYPE string,
|
|
||||||
late_deser TYPE string,
|
|
||||||
END OF ty_metadata.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_web_asset,
|
|
||||||
url TYPE w3url,
|
|
||||||
content TYPE string,
|
|
||||||
END OF ty_web_asset.
|
|
||||||
TYPES tt_web_assets TYPE STANDARD TABLE OF ty_web_asset WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_repo_file,
|
|
||||||
path TYPE string,
|
|
||||||
filename TYPE string,
|
|
||||||
is_changed TYPE abap_bool,
|
|
||||||
END OF ty_repo_file.
|
|
||||||
TYPES tt_repo_files TYPE STANDARD TABLE OF ty_repo_file WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF gc_type,
|
|
||||||
commit TYPE ty_type VALUE 'commit', "#EC NOTEXT
|
|
||||||
tree TYPE ty_type VALUE 'tree', "#EC NOTEXT
|
|
||||||
ref_d TYPE ty_type VALUE 'ref_d', "#EC NOTEXT
|
|
||||||
blob TYPE ty_type VALUE 'blob', "#EC NOTEXT
|
|
||||||
END OF gc_type.
|
|
||||||
|
|
||||||
TYPES: ty_chmod TYPE c LENGTH 6.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_object,
|
|
||||||
sha1 TYPE ty_sha1,
|
|
||||||
type TYPE ty_type,
|
|
||||||
data TYPE xstring,
|
|
||||||
END OF ty_object.
|
|
||||||
TYPES: ty_objects_tt TYPE STANDARD TABLE OF ty_object WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_tadir,
|
|
||||||
pgmid TYPE tadir-pgmid,
|
|
||||||
object TYPE tadir-object,
|
|
||||||
obj_name TYPE tadir-obj_name,
|
|
||||||
devclass TYPE tadir-devclass,
|
|
||||||
korrnum TYPE tadir-korrnum,
|
|
||||||
path TYPE string,
|
|
||||||
END OF ty_tadir.
|
|
||||||
TYPES: ty_tadir_tt TYPE STANDARD TABLE OF ty_tadir WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
TYPES: BEGIN OF ty_result,
|
|
||||||
obj_type TYPE tadir-object,
|
|
||||||
obj_name TYPE tadir-obj_name,
|
|
||||||
match TYPE sap_bool,
|
|
||||||
filename TYPE string,
|
|
||||||
package TYPE devclass,
|
|
||||||
path TYPE string,
|
|
||||||
END OF ty_result.
|
|
||||||
TYPES: ty_results_tt TYPE STANDARD TABLE OF ty_result WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF gc_chmod,
|
|
||||||
file TYPE ty_chmod VALUE '100644',
|
|
||||||
executable TYPE ty_chmod VALUE '100755',
|
|
||||||
dir TYPE ty_chmod VALUE '40000 ',
|
|
||||||
END OF gc_chmod.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF gc_event_state,
|
|
||||||
not_handled VALUE 0,
|
|
||||||
re_render VALUE 1,
|
|
||||||
new_page VALUE 2,
|
|
||||||
go_back VALUE 3,
|
|
||||||
no_more_act VALUE 4,
|
|
||||||
new_page_w_bookmark VALUE 5,
|
|
||||||
go_back_to_bookmark VALUE 6,
|
|
||||||
END OF gc_event_state.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF gc_html_opt,
|
|
||||||
emphas TYPE c VALUE 'E',
|
|
||||||
cancel TYPE c VALUE 'C',
|
|
||||||
END OF gc_html_opt.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF gc_action_type,
|
|
||||||
sapevent TYPE c VALUE 'E',
|
|
||||||
url TYPE c VALUE 'U',
|
|
||||||
onclick TYPE c VALUE 'C',
|
|
||||||
END OF gc_action_type.
|
|
||||||
|
|
||||||
CONSTANTS: gc_newline TYPE abap_char1 VALUE cl_abap_char_utilities=>newline.
|
|
||||||
|
|
||||||
CONSTANTS: gc_english TYPE spras VALUE 'E'.
|
|
||||||
|
|
||||||
CONSTANTS: gc_abapgit_homepage TYPE string VALUE 'http://www.abapgit.org'.
|
|
||||||
|
|
||||||
CONSTANTS: gc_root_dir TYPE string VALUE '/',
|
|
||||||
gc_dot_abapgit TYPE string VALUE '.abapgit.xml'.
|
|
||||||
|
|
||||||
DEFINE _raise.
|
|
||||||
RAISE EXCEPTION TYPE lcx_exception
|
|
||||||
EXPORTING
|
|
||||||
iv_text = &1. "#EC NOTEXT
|
|
||||||
END-OF-DEFINITION.
|
|
||||||
|
|
||||||
******************
|
|
||||||
|
|
||||||
SELECTION-SCREEN BEGIN OF SCREEN 1001.
|
SELECTION-SCREEN BEGIN OF SCREEN 1001.
|
||||||
* dummy for triggering screen
|
* dummy for triggering screen
|
||||||
SELECTION-SCREEN END OF SCREEN 1001.
|
SELECTION-SCREEN END OF SCREEN 1001.
|
||||||
|
|
||||||
******************
|
INCLUDE zabapgit_definitions.
|
||||||
INCLUDE zabapgit_exceptions.
|
INCLUDE zabapgit_exceptions.
|
||||||
INCLUDE zabapgit_zlib.
|
INCLUDE zabapgit_zlib.
|
||||||
INCLUDE zabapgit_util.
|
INCLUDE zabapgit_util.
|
||||||
INCLUDE zabapgit_xml.
|
INCLUDE zabapgit_xml.
|
||||||
|
|
||||||
CLASS lcl_gui DEFINITION DEFERRED.
|
CLASS lcl_gui DEFINITION DEFERRED.
|
||||||
CLASS lcl_persistence_user DEFINITION DEFERRED.
|
CLASS lcl_persistence_user DEFINITION DEFERRED.
|
||||||
CLASS lcl_repo_srv DEFINITION DEFERRED.
|
CLASS lcl_repo_srv DEFINITION DEFERRED.
|
||||||
CLASS lcl_persistence_db DEFINITION DEFERRED.
|
CLASS lcl_persistence_db DEFINITION DEFERRED.
|
||||||
|
INCLUDE zabapgit_app.
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
* CLASS lcl_app DEFINITION
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
CLASS lcl_app DEFINITION FINAL.
|
|
||||||
PUBLIC SECTION.
|
|
||||||
|
|
||||||
CLASS-METHODS run
|
|
||||||
RAISING lcx_exception.
|
|
||||||
|
|
||||||
CLASS-METHODS gui
|
|
||||||
RETURNING VALUE(ro_gui) TYPE REF TO lcl_gui
|
|
||||||
RAISING lcx_exception.
|
|
||||||
|
|
||||||
CLASS-METHODS user
|
|
||||||
IMPORTING iv_user TYPE xubname DEFAULT sy-uname
|
|
||||||
RETURNING VALUE(ro_user) TYPE REF TO lcl_persistence_user
|
|
||||||
RAISING lcx_exception.
|
|
||||||
|
|
||||||
CLASS-METHODS repo_srv
|
|
||||||
RETURNING VALUE(ro_repo_srv) TYPE REF TO lcl_repo_srv.
|
|
||||||
|
|
||||||
CLASS-METHODS db
|
|
||||||
RETURNING VALUE(ro_db) TYPE REF TO lcl_persistence_db.
|
|
||||||
|
|
||||||
PRIVATE SECTION.
|
|
||||||
CLASS-DATA: go_gui TYPE REF TO lcl_gui,
|
|
||||||
go_current_user TYPE REF TO lcl_persistence_user,
|
|
||||||
go_db TYPE REF TO lcl_persistence_db,
|
|
||||||
go_repo_srv TYPE REF TO lcl_repo_srv.
|
|
||||||
|
|
||||||
ENDCLASS. "lcl_app
|
|
||||||
|
|
||||||
INCLUDE zabapgit_persistence.
|
INCLUDE zabapgit_persistence.
|
||||||
INCLUDE zabapgit_html.
|
INCLUDE zabapgit_html.
|
||||||
INCLUDE zabapgit_dot_abapgit.
|
INCLUDE zabapgit_dot_abapgit.
|
||||||
INCLUDE zabapgit_sap_package.
|
INCLUDE zabapgit_sap_package.
|
||||||
|
|
||||||
CLASS lcl_repo_online DEFINITION DEFERRED.
|
CLASS lcl_repo_online DEFINITION DEFERRED.
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
* CLASS lcl_stage DEFINITION
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
|
||||||
|
|
||||||
PUBLIC SECTION.
|
|
||||||
TYPES: ty_method TYPE c LENGTH 1.
|
|
||||||
|
|
||||||
CONSTANTS: BEGIN OF c_method,
|
|
||||||
add TYPE ty_method VALUE 'A',
|
|
||||||
rm TYPE ty_method VALUE 'R',
|
|
||||||
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,
|
|
||||||
END OF ty_stage.
|
|
||||||
|
|
||||||
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:
|
|
||||||
add
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
RAISING lcx_exception,
|
|
||||||
reset
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
RAISING lcx_exception,
|
|
||||||
rm
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
RAISING lcx_exception,
|
|
||||||
ignore
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
RAISING lcx_exception,
|
|
||||||
lookup
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
RETURNING VALUE(rv_method) TYPE ty_method,
|
|
||||||
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.
|
|
||||||
|
|
||||||
METHODS append
|
|
||||||
IMPORTING iv_path TYPE ty_file-path
|
|
||||||
iv_filename TYPE ty_file-filename
|
|
||||||
iv_method TYPE ty_method
|
|
||||||
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
|
|
||||||
|
|
||||||
INCLUDE zabapgit_repo.
|
|
||||||
INCLUDE zabapgit_stage.
|
INCLUDE zabapgit_stage.
|
||||||
|
INCLUDE zabapgit_repo.
|
||||||
|
INCLUDE zabapgit_stage_impl.
|
||||||
INCLUDE zabapgit_git.
|
INCLUDE zabapgit_git.
|
||||||
INCLUDE zabapgit_objects.
|
INCLUDE zabapgit_objects.
|
||||||
INCLUDE zabapgit_tadir.
|
INCLUDE zabapgit_tadir.
|
||||||
|
|
35
src/zabapgit_app.prog.abap
Normal file
35
src/zabapgit_app.prog.abap
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Include ZABAPGIT_APP
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
*----------------------------------------------------------------------*
|
||||||
|
* CLASS lcl_app DEFINITION
|
||||||
|
*----------------------------------------------------------------------*
|
||||||
|
CLASS lcl_app DEFINITION FINAL.
|
||||||
|
PUBLIC SECTION.
|
||||||
|
|
||||||
|
CLASS-METHODS run
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
CLASS-METHODS gui
|
||||||
|
RETURNING VALUE(ro_gui) TYPE REF TO lcl_gui
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
CLASS-METHODS user
|
||||||
|
IMPORTING iv_user TYPE xubname DEFAULT sy-uname
|
||||||
|
RETURNING VALUE(ro_user) TYPE REF TO lcl_persistence_user
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
|
CLASS-METHODS repo_srv
|
||||||
|
RETURNING VALUE(ro_repo_srv) TYPE REF TO lcl_repo_srv.
|
||||||
|
|
||||||
|
CLASS-METHODS db
|
||||||
|
RETURNING VALUE(ro_db) TYPE REF TO lcl_persistence_db.
|
||||||
|
|
||||||
|
PRIVATE SECTION.
|
||||||
|
CLASS-DATA: go_gui TYPE REF TO lcl_gui,
|
||||||
|
go_current_user TYPE REF TO lcl_persistence_user,
|
||||||
|
go_db TYPE REF TO lcl_persistence_db,
|
||||||
|
go_repo_srv TYPE REF TO lcl_repo_srv.
|
||||||
|
|
||||||
|
ENDCLASS. "lcl_app
|
48
src/zabapgit_app.prog.xml
Normal file
48
src/zabapgit_app.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_APP</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_APP</ENTRY>
|
||||||
|
<LENGTH>20</LENGTH>
|
||||||
|
<SPLIT/>
|
||||||
|
</item>
|
||||||
|
</TPOOL>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
134
src/zabapgit_definitions.prog.abap
Normal file
134
src/zabapgit_definitions.prog.abap
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Include ZABAPGIT_DEFINITIONS
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
|
||||||
|
TYPE-POOLS seop.
|
||||||
|
|
||||||
|
TYPES: ty_type TYPE c LENGTH 6,
|
||||||
|
ty_bitbyte TYPE c LENGTH 8,
|
||||||
|
ty_sha1 TYPE c LENGTH 40.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_file,
|
||||||
|
path TYPE string,
|
||||||
|
filename TYPE string,
|
||||||
|
data TYPE xstring,
|
||||||
|
END OF ty_file.
|
||||||
|
TYPES: ty_files_tt TYPE STANDARD TABLE OF ty_file WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: ty_string_tt TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
|
||||||
|
TYPES: tt_w3urls TYPE STANDARD TABLE OF w3url WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_comment,
|
||||||
|
username TYPE string,
|
||||||
|
email TYPE string,
|
||||||
|
comment TYPE string,
|
||||||
|
END OF ty_comment.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_item,
|
||||||
|
obj_type TYPE tadir-object,
|
||||||
|
obj_name TYPE tadir-obj_name,
|
||||||
|
END OF ty_item.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_file_item,
|
||||||
|
file TYPE ty_file,
|
||||||
|
item TYPE ty_item,
|
||||||
|
END OF ty_file_item.
|
||||||
|
TYPES: ty_files_item_tt TYPE STANDARD TABLE OF ty_file_item WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_metadata,
|
||||||
|
class TYPE string,
|
||||||
|
version TYPE string,
|
||||||
|
late_deser TYPE string,
|
||||||
|
END OF ty_metadata.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_web_asset,
|
||||||
|
url TYPE w3url,
|
||||||
|
content TYPE string,
|
||||||
|
END OF ty_web_asset.
|
||||||
|
TYPES tt_web_assets TYPE STANDARD TABLE OF ty_web_asset WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_repo_file,
|
||||||
|
path TYPE string,
|
||||||
|
filename TYPE string,
|
||||||
|
is_changed TYPE abap_bool,
|
||||||
|
END OF ty_repo_file.
|
||||||
|
TYPES tt_repo_files TYPE STANDARD TABLE OF ty_repo_file WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
CONSTANTS: BEGIN OF gc_type,
|
||||||
|
commit TYPE ty_type VALUE 'commit', "#EC NOTEXT
|
||||||
|
tree TYPE ty_type VALUE 'tree', "#EC NOTEXT
|
||||||
|
ref_d TYPE ty_type VALUE 'ref_d', "#EC NOTEXT
|
||||||
|
blob TYPE ty_type VALUE 'blob', "#EC NOTEXT
|
||||||
|
END OF gc_type.
|
||||||
|
|
||||||
|
TYPES: ty_chmod TYPE c LENGTH 6.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_object,
|
||||||
|
sha1 TYPE ty_sha1,
|
||||||
|
type TYPE ty_type,
|
||||||
|
data TYPE xstring,
|
||||||
|
END OF ty_object.
|
||||||
|
TYPES: ty_objects_tt TYPE STANDARD TABLE OF ty_object WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_tadir,
|
||||||
|
pgmid TYPE tadir-pgmid,
|
||||||
|
object TYPE tadir-object,
|
||||||
|
obj_name TYPE tadir-obj_name,
|
||||||
|
devclass TYPE tadir-devclass,
|
||||||
|
korrnum TYPE tadir-korrnum,
|
||||||
|
path TYPE string,
|
||||||
|
END OF ty_tadir.
|
||||||
|
TYPES: ty_tadir_tt TYPE STANDARD TABLE OF ty_tadir WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_result,
|
||||||
|
obj_type TYPE tadir-object,
|
||||||
|
obj_name TYPE tadir-obj_name,
|
||||||
|
match TYPE sap_bool,
|
||||||
|
filename TYPE string,
|
||||||
|
package TYPE devclass,
|
||||||
|
path TYPE string,
|
||||||
|
END OF ty_result.
|
||||||
|
TYPES: ty_results_tt TYPE STANDARD TABLE OF ty_result WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
CONSTANTS: BEGIN OF gc_chmod,
|
||||||
|
file TYPE ty_chmod VALUE '100644',
|
||||||
|
executable TYPE ty_chmod VALUE '100755',
|
||||||
|
dir TYPE ty_chmod VALUE '40000 ',
|
||||||
|
END OF gc_chmod.
|
||||||
|
|
||||||
|
CONSTANTS: BEGIN OF gc_event_state,
|
||||||
|
not_handled VALUE 0,
|
||||||
|
re_render VALUE 1,
|
||||||
|
new_page VALUE 2,
|
||||||
|
go_back VALUE 3,
|
||||||
|
no_more_act VALUE 4,
|
||||||
|
new_page_w_bookmark VALUE 5,
|
||||||
|
go_back_to_bookmark VALUE 6,
|
||||||
|
END OF gc_event_state.
|
||||||
|
|
||||||
|
CONSTANTS: BEGIN OF gc_html_opt,
|
||||||
|
emphas TYPE c VALUE 'E',
|
||||||
|
cancel TYPE c VALUE 'C',
|
||||||
|
END OF gc_html_opt.
|
||||||
|
|
||||||
|
CONSTANTS: BEGIN OF gc_action_type,
|
||||||
|
sapevent TYPE c VALUE 'E',
|
||||||
|
url TYPE c VALUE 'U',
|
||||||
|
onclick TYPE c VALUE 'C',
|
||||||
|
END OF gc_action_type.
|
||||||
|
|
||||||
|
CONSTANTS: gc_newline TYPE abap_char1 VALUE cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
|
CONSTANTS: gc_english TYPE spras VALUE 'E'.
|
||||||
|
|
||||||
|
CONSTANTS: gc_abapgit_homepage TYPE string VALUE 'http://www.abapgit.org'.
|
||||||
|
|
||||||
|
CONSTANTS: gc_root_dir TYPE string VALUE '/',
|
||||||
|
gc_dot_abapgit TYPE string VALUE '.abapgit.xml'.
|
||||||
|
|
||||||
|
DEFINE _raise.
|
||||||
|
RAISE EXCEPTION TYPE lcx_exception
|
||||||
|
EXPORTING
|
||||||
|
iv_text = &1. "#EC NOTEXT
|
||||||
|
END-OF-DEFINITION.
|
48
src/zabapgit_definitions.prog.xml
Normal file
48
src/zabapgit_definitions.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_DEFINITIONS</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_DEFINITIONS</ENTRY>
|
||||||
|
<LENGTH>28</LENGTH>
|
||||||
|
<SPLIT/>
|
||||||
|
</item>
|
||||||
|
</TPOOL>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
|
@ -2,245 +2,94 @@
|
||||||
*& Include ZABAPGIT_STAGE
|
*& Include ZABAPGIT_STAGE
|
||||||
*&---------------------------------------------------------------------*
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
CLASS lcl_stage_logic DEFINITION FINAL.
|
*----------------------------------------------------------------------*
|
||||||
|
* CLASS lcl_stage DEFINITION
|
||||||
|
*----------------------------------------------------------------------*
|
||||||
|
CLASS lcl_stage DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_repo_srv.
|
||||||
|
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
TYPES: BEGIN OF ty_stage_files,
|
TYPES: ty_method TYPE c LENGTH 1.
|
||||||
local TYPE ty_files_item_tt,
|
|
||||||
remote TYPE ty_files_tt,
|
|
||||||
END OF ty_stage_files.
|
|
||||||
|
|
||||||
CLASS-METHODS:
|
CONSTANTS: BEGIN OF c_method,
|
||||||
get
|
add TYPE ty_method VALUE 'A',
|
||||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
rm TYPE ty_method VALUE 'R',
|
||||||
RETURNING VALUE(rs_files) TYPE ty_stage_files
|
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,
|
||||||
|
END OF ty_stage.
|
||||||
|
|
||||||
|
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:
|
||||||
|
add
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
RAISING lcx_exception,
|
RAISING lcx_exception,
|
||||||
|
reset
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
|
RAISING lcx_exception,
|
||||||
|
rm
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
|
RAISING lcx_exception,
|
||||||
|
ignore
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
|
RAISING lcx_exception,
|
||||||
|
lookup
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
|
RETURNING VALUE(rv_method) TYPE ty_method,
|
||||||
count
|
count
|
||||||
IMPORTING io_repo TYPE REF TO lcl_repo_online
|
RETURNING VALUE(rv_count) TYPE i,
|
||||||
RETURNING VALUE(rv_count) TYPE i
|
get_all
|
||||||
RAISING lcx_exception.
|
RETURNING VALUE(rt_stage) TYPE ty_stage_tt.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
CLASS-METHODS:
|
DATA: mt_stage TYPE ty_stage_tt.
|
||||||
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.
|
METHODS append
|
||||||
|
IMPORTING iv_path TYPE ty_file-path
|
||||||
|
iv_filename TYPE ty_file-filename
|
||||||
|
iv_method TYPE ty_method
|
||||||
|
RAISING lcx_exception.
|
||||||
|
|
||||||
CLASS lcl_stage_logic IMPLEMENTATION.
|
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.
|
||||||
|
|
||||||
METHOD get.
|
ENDCLASS. "lcl_stage DEFINITION
|
||||||
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.
|
|
246
src/zabapgit_stage_impl.prog.abap
Normal file
246
src/zabapgit_stage_impl.prog.abap
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& 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.
|
48
src/zabapgit_stage_impl.prog.xml
Normal file
48
src/zabapgit_stage_impl.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_IMPL</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_IMPL</ENTRY>
|
||||||
|
<LENGTH>27</LENGTH>
|
||||||
|
<SPLIT/>
|
||||||
|
</item>
|
||||||
|
</TPOOL>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
Loading…
Reference in New Issue
Block a user