larshp/upDOWNci

push/pull to/from git

larshp opened this issue · 2 comments

push/pull to/from git

quick and very dirty:

REPORT ztest.

PARAMETERS: p_user TYPE sci_user,
            p_name TYPE sci_chkv OBLIGATORY,
            p_repo TYPE zabapgit-value OBLIGATORY.

START-OF-SELECTION.
  PERFORM run.

FORM run.

  TRY.
      DATA(lv_xml) = zcl_updownci=>build_xml(
        iv_name  = p_name
        iv_user  = p_user ).

      SELECT SINGLE unam FROM scichkv_hd INTO @DATA(lv_unam)
        WHERE ciuser = @p_user AND checkvname = @p_name.

      DATA(lo_online) = CAST zcl_abapgit_repo_online( zcl_abapgit_repo_srv=>get_instance( )->get( p_repo ) ).

      DATA(lt_files) = lo_online->get_files_remote( ).
      DATA(lv_data) = zcl_abapgit_convert=>string_to_xstring_utf8( lv_xml ).
      DATA(lv_filename) = |{ p_name }.xml|.
      READ TABLE lt_files WITH KEY filename = lv_filename data = lv_data TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        WRITE: / 'no changes'.
        RETURN.
      ENDIF.

      DATA(ls_comment) = VALUE zif_abapgit_definitions=>ty_comment(
        committer-name  = lv_unam
        committer-email = |{ lv_unam }@localhost|
        comment         = 'Updated' ).

      DATA(lo_stage) = NEW zcl_abapgit_stage(
        iv_branch_name = lo_online->get_branch_name( )
        iv_branch_sha1 = lo_online->get_sha1_remote( ) ).

      lo_stage->add(
        iv_path     = '/'
        iv_filename = lv_filename
        iv_data     = lv_data ).

      zcl_abapgit_git_porcelain=>push(
        io_repo    = lo_online
        is_comment = ls_comment
        io_stage   = lo_stage ).

    CATCH zcx_updownci_exception INTO DATA(lx_updownci).
      WRITE: / lx_updownci->iv_text.
    CATCH cx_static_check INTO DATA(lx_error).
      WRITE: / 'Error'.
      MESSAGE lx_error TYPE 'E'.
  ENDTRY.

ENDFORM.

We can close this issue, right? I don't think we'll ever want to introduce a dependency to abapGit into this repository.