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