mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
fix #864
This commit is contained in:
parent
faaf1efd28
commit
fb08006b95
|
@ -612,6 +612,7 @@ CLASS lcl_git_pack IMPLEMENTATION.
|
|||
|
||||
DATA: lv_string TYPE string,
|
||||
lv_word TYPE string,
|
||||
lv_length TYPE i,
|
||||
lv_trash TYPE string ##NEEDED,
|
||||
lt_string TYPE TABLE OF string.
|
||||
|
||||
|
@ -623,34 +624,41 @@ CLASS lcl_git_pack IMPLEMENTATION.
|
|||
SPLIT lv_string AT lif_defs=>gc_newline INTO TABLE lt_string.
|
||||
|
||||
LOOP AT lt_string ASSIGNING <lv_string>.
|
||||
IF NOT rs_commit-committer IS INITIAL.
|
||||
CONCATENATE rs_commit-body <lv_string> INTO rs_commit-body
|
||||
SEPARATED BY lif_defs=>gc_newline.
|
||||
ELSE.
|
||||
SPLIT <lv_string> AT space INTO lv_word lv_trash.
|
||||
CASE lv_word.
|
||||
WHEN 'tree'.
|
||||
rs_commit-tree = <lv_string>+5.
|
||||
WHEN 'parent'.
|
||||
IF rs_commit-parent IS INITIAL.
|
||||
rs_commit-parent = <lv_string>+7.
|
||||
ELSE.
|
||||
rs_commit-parent2 = <lv_string>+7.
|
||||
ENDIF.
|
||||
WHEN 'author'.
|
||||
rs_commit-author = <lv_string>+7.
|
||||
WHEN 'committer'.
|
||||
rs_commit-committer = <lv_string>+10.
|
||||
WHEN OTHERS.
|
||||
ASSERT 0 = 1.
|
||||
ENDCASE.
|
||||
ENDIF.
|
||||
* IF NOT rs_commit-committer IS INITIAL.
|
||||
* CONCATENATE rs_commit-body <lv_string> INTO rs_commit-body
|
||||
* SEPARATED BY lif_defs=>gc_newline.
|
||||
* ELSE.
|
||||
lv_length = strlen( <lv_string> ) + 1.
|
||||
lv_string = lv_string+lv_length.
|
||||
|
||||
SPLIT <lv_string> AT space INTO lv_word lv_trash.
|
||||
CASE lv_word.
|
||||
WHEN 'tree'.
|
||||
rs_commit-tree = <lv_string>+5.
|
||||
WHEN 'parent'.
|
||||
IF rs_commit-parent IS INITIAL.
|
||||
rs_commit-parent = <lv_string>+7.
|
||||
ELSE.
|
||||
rs_commit-parent2 = <lv_string>+7.
|
||||
ENDIF.
|
||||
WHEN 'author'.
|
||||
rs_commit-author = <lv_string>+7.
|
||||
WHEN 'committer'.
|
||||
rs_commit-committer = <lv_string>+10.
|
||||
EXIT. " current loop
|
||||
WHEN OTHERS.
|
||||
ASSERT 0 = 1.
|
||||
ENDCASE.
|
||||
|
||||
* ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
rs_commit-body = lv_string+1.
|
||||
|
||||
* strip first newline
|
||||
IF strlen( rs_commit-body ) >= 2.
|
||||
rs_commit-body = rs_commit-body+2.
|
||||
ENDIF.
|
||||
* IF strlen( rs_commit-body ) >= 2.
|
||||
* rs_commit-body = rs_commit-body+2.
|
||||
* ENDIF.
|
||||
|
||||
IF rs_commit-author IS INITIAL
|
||||
OR rs_commit-committer IS INITIAL
|
||||
|
|
|
@ -1004,9 +1004,6 @@ CLASS ltcl_git_pack_decode_commit IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-committer
|
||||
exp = 'committer' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-body
|
||||
exp = 'comment' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-parent
|
||||
exp = 'parent1' ).
|
||||
|
@ -1014,6 +1011,10 @@ CLASS ltcl_git_pack_decode_commit IMPLEMENTATION.
|
|||
act = ms_raw-parent2
|
||||
exp = 'parent2' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_char_cp(
|
||||
act = ms_raw-body
|
||||
exp = 'comment+' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD decode2.
|
||||
|
@ -1035,13 +1036,14 @@ CLASS ltcl_git_pack_decode_commit IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-committer
|
||||
exp = 'committer' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-body
|
||||
exp = 'comment' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-parent
|
||||
exp = '' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_char_cp(
|
||||
act = ms_raw-body
|
||||
exp = 'comment+' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD decode3.
|
||||
|
@ -1064,13 +1066,14 @@ CLASS ltcl_git_pack_decode_commit IMPLEMENTATION.
|
|||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-committer
|
||||
exp = 'committer' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-body
|
||||
exp = 'comment' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = ms_raw-parent
|
||||
exp = 'parent1' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_char_cp(
|
||||
act = ms_raw-body
|
||||
exp = 'comment+' ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
@ -1084,11 +1087,15 @@ CLASS ltcl_git_pack DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FI
|
|||
|
||||
PRIVATE SECTION.
|
||||
|
||||
CONSTANTS: c_sha TYPE lif_defs=>ty_sha1 VALUE '5f46cb3c4b7f0b3600b64f744cde614a283a88dc'.
|
||||
|
||||
METHODS:
|
||||
tree FOR TESTING
|
||||
RAISING lcx_exception,
|
||||
commit FOR TESTING
|
||||
RAISING lcx_exception,
|
||||
commit_newline FOR TESTING
|
||||
RAISING lcx_exception,
|
||||
pack_short FOR TESTING
|
||||
RAISING lcx_exception,
|
||||
pack_long FOR TESTING
|
||||
|
@ -1326,8 +1333,6 @@ CLASS ltcl_git_pack IMPLEMENTATION.
|
|||
|
||||
METHOD tree.
|
||||
|
||||
CONSTANTS: lc_sha TYPE lif_defs=>ty_sha1 VALUE '5f46cb3c4b7f0b3600b64f744cde614a283a88dc'.
|
||||
|
||||
DATA: lt_nodes TYPE lcl_git_pack=>ty_nodes_tt,
|
||||
ls_node LIKE LINE OF lt_nodes,
|
||||
lv_data TYPE xstring,
|
||||
|
@ -1336,7 +1341,7 @@ CLASS ltcl_git_pack IMPLEMENTATION.
|
|||
CLEAR ls_node.
|
||||
ls_node-chmod = lif_defs=>gc_chmod-file.
|
||||
ls_node-name = 'foobar.txt'.
|
||||
ls_node-sha1 = lc_sha.
|
||||
ls_node-sha1 = c_sha.
|
||||
APPEND ls_node TO lt_nodes.
|
||||
|
||||
lv_data = lcl_git_pack=>encode_tree( lt_nodes ).
|
||||
|
@ -1350,16 +1355,13 @@ CLASS ltcl_git_pack IMPLEMENTATION.
|
|||
|
||||
METHOD commit.
|
||||
|
||||
CONSTANTS: lc_tree TYPE lif_defs=>ty_sha1 VALUE '5f46cb3c4b7f0b3600b64f744cde614a283a88dc',
|
||||
lc_parent TYPE lif_defs=>ty_sha1 VALUE '1236cb3c4b7f0b3600b64f744cde614a283a88dc'.
|
||||
|
||||
DATA: ls_commit TYPE lcl_git_pack=>ty_commit,
|
||||
ls_result TYPE lcl_git_pack=>ty_commit,
|
||||
lv_data TYPE xstring.
|
||||
|
||||
|
||||
ls_commit-tree = lc_tree.
|
||||
ls_commit-parent = lc_parent.
|
||||
ls_commit-tree = c_sha.
|
||||
ls_commit-parent = c_sha.
|
||||
ls_commit-author = 'larshp <larshp@hotmail.com> 1387823471 +0100'.
|
||||
ls_commit-committer = 'larshp <larshp@hotmail.com> 1387823471 +0100'.
|
||||
ls_commit-body = 'very informative'.
|
||||
|
@ -1373,6 +1375,28 @@ CLASS ltcl_git_pack IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD. "commit
|
||||
|
||||
METHOD commit_newline.
|
||||
|
||||
DATA: ls_commit TYPE lcl_git_pack=>ty_commit,
|
||||
ls_result TYPE lcl_git_pack=>ty_commit,
|
||||
lv_data TYPE xstring.
|
||||
|
||||
|
||||
ls_commit-tree = c_sha.
|
||||
ls_commit-parent = c_sha.
|
||||
ls_commit-author = 'larshp <larshp@hotmail.com> 1387823471 +0100'.
|
||||
ls_commit-committer = 'larshp <larshp@hotmail.com> 1387823471 +0100'.
|
||||
ls_commit-body = 'very informative' && lif_defs=>gc_newline && lif_defs=>gc_newline.
|
||||
|
||||
lv_data = lcl_git_pack=>encode_commit( ls_commit ).
|
||||
ls_result = lcl_git_pack=>decode_commit( lv_data ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = ls_commit
|
||||
act = ls_result ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS. "lcl_abap_unit IMPLEMENTATION
|
||||
|
||||
CLASS ltcl_html DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
||||
|
|
Loading…
Reference in New Issue
Block a user