Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.28 KB | None | 0 0
  1.  METHOD transport_to_pull_request.
  2.     DATA:
  3.       lo_repo             TYPE REF TO lcl_repo_online,
  4.       ls_transport_object LIKE LINE OF it_transport_objects,
  5.       lt_items            TYPE ty_files_item_tt,
  6.       ls_file             LIKE LINE OF lt_items,
  7.       ls_item             TYPE string,
  8.       lv_branch_name      TYPE string,
  9.       ls_comment          TYPE ty_comment.
  10.  
  11.     BREAK copat.
  12.     lo_repo ?= lcl_app=>repo_srv( )->get( iv_repository_key ).
  13.  
  14.     lv_branch_name = lcl_git_branch_list=>complete_heads_branch_name(
  15.         lcl_git_branch_list=>normalize_branch_name( is_branch_pull_request-branch_name ) ).
  16.  
  17.     ASSERT lv_branch_name CP 'refs/heads/+*'.
  18.  
  19.     lcl_git_porcelain=>create_branch(
  20.       io_repo = lo_repo
  21.       iv_name = lv_branch_name
  22.       iv_from = lo_repo->get_sha1_local( ) ).
  23.  
  24.     lo_repo->set_branch_name( lv_branch_name ).
  25.  
  26.     DATA lo_stage TYPE REF TO lcl_stage.
  27.     CREATE OBJECT lo_stage
  28.       EXPORTING
  29.         iv_branch_name = lv_branch_name
  30.         iv_branch_sha1 = lo_repo->get_sha1_remote( ).
  31.  
  32.     DATA:         ls_stage_files   TYPE ty_stage_files.
  33.  
  34.  
  35.     ls_stage_files = lcl_stage_logic=>get( lo_repo ).
  36.  
  37.     "We only need to add the new local objects,
  38.     "deleted files are, apparently, excluded
  39.     LOOP AT ls_stage_files-local INTO ls_file.
  40.       lo_stage->add(
  41.         iv_path       = ls_file-file-path
  42.         iv_filename   = ls_file-file-filename
  43.         iv_data       = ls_file-file-data
  44.       ).
  45.     ENDLOOP.
  46.  
  47.     DATA ls_remote_file LIKE line of ls_stage_files-remote.
  48.  
  49.     LOOP AT ls_stage_files-remote INTO ls_remote_file.
  50.       lo_stage->rm(
  51.         iv_path       = ls_remote_file-path
  52.         iv_filename   = ls_remote_file-filename
  53.       ).
  54.     endloop.
  55. *        CATCH lcx_exception.    "
  56.  
  57.     FIELD-SYMBOLS: <ls_local> LIKE LINE OF ls_stage_files-local.
  58.  
  59.     READ TABLE ls_stage_files-local INDEX 1 ASSIGNING <ls_local>.
  60.     IF sy-subrc <> 0.
  61.       EXIT.
  62.     ENDIF.
  63.  
  64.     CLEAR ls_comment.
  65.     ls_comment-committer-name  = lcl_objects=>changed_by( <ls_local>-item ).
  66.     ls_comment-committer-email = |{ ls_comment-committer-name }@localhost|.
  67.     ls_comment-comment        = is_branch_pull_request-commit_text.
  68.  
  69.     lo_repo->push( is_comment = ls_comment
  70.                    io_stage   = lo_stage ).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement