<commit_before>CLASS zcl_abapgit_services_repo DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    CLASS-METHODS new_online
      IMPORTING
        !iv_url        TYPE string
      RETURNING
        VALUE(ro_repo) TYPE REF TO zcl_abapgit_repo_online
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS refresh
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS remove
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS purge
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS new_offline
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_attach
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_detach
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_change
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS refresh_local_checksums
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS toggle_favorite
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS open_se80
      IMPORTING
        !iv_package TYPE devclass
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS transport_to_branch
      IMPORTING
        !iv_repository_key TYPE zif_abapgit_persistence=>ty_value
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS gui_deserialize
      IMPORTING
        !io_repo TYPE REF TO zcl_abapgit_repo
      RAISING
        zcx_abapgit_exception .
  PROTECTED SECTION.
  PRIVATE SECTION.

    CLASS-METHODS popup_overwrite
      CHANGING
        !ct_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS popup_package_overwrite
      CHANGING
        !ct_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt
      RAISING
        zcx_abapgit_exception.
ENDCLASS.



CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.


  METHOD gui_deserialize.

    DATA: ls_checks       TYPE zif_abapgit_definitions=>ty_deserialize_checks,
          lt_requirements TYPE zif_abapgit_dot_abapgit=>ty_requirement_tt,
          lt_dependencies TYPE zif_abapgit_apack_definitions=>tt_dependencies.


* find troublesome objects
    ls_checks = io_repo->deserialize_checks( ).

* and let the user decide what to do
    TRY.
        popup_overwrite( CHANGING ct_overwrite = ls_checks-overwrite ).
        popup_package_overwrite( CHANGING ct_overwrite = ls_checks-warning_package ).

        IF ls_checks-requirements-met = zif_abapgit_definitions=>gc_no.
          lt_requirements = io_repo->get_dot_abapgit( )->get_data( )-requirements.
          zcl_abapgit_requirement_helper=>requirements_popup( lt_requirements ).
          ls_checks-requirements-decision = zif_abapgit_definitions=>gc_yes.
        ENDIF.

        IF ls_checks-dependencies-met = zif_abapgit_definitions=>gc_no.
          lt_dependencies = io_repo->get_dot_apack( )->get_manifest_descriptor( )-dependencies.
          zcl_abapgit_apack_helper=>dependencies_popup( lt_dependencies ).
        ENDIF.

        IF ls_checks-transport-required = abap_true.
          ls_checks-transport-transport = zcl_abapgit_ui_factory=>get_popups( )->popup_transport_request(
            is_transport_type = ls_checks-transport-type ).
        ENDIF.

      CATCH zcx_abapgit_cancel.
        RETURN.
    ENDTRY.

* and pass decisions to deserialize
    io_repo->deserialize( is_checks = ls_checks
                          ii_log    = io_repo->create_new_log( 'Pull Log' ) ).

  ENDMETHOD.


  METHOD new_offline.

    DATA: ls_popup        TYPE zif_abapgit_popups=>ty_popup,
          lo_repo         TYPE REF TO zcl_abapgit_repo,
          lo_repo_offline TYPE REF TO zcl_abapgit_repo_offline,
          lv_reason       TYPE string.

    ls_popup  = zcl_abapgit_ui_factory=>get_popups( )->repo_new_offline( ).
    IF ls_popup-cancel = abap_true.
      RAISE EXCEPTION TYPE zcx_abapgit_cancel.
    ENDIF.

    " make sure package is not already in use for a different repository
    zcl_abapgit_repo_srv=>get_instance( )->get_repo_from_package(
      EXPORTING
        iv_package = ls_popup-package
      IMPORTING
        eo_repo    = lo_repo
        ev_reason  = lv_reason ).

    IF lo_repo IS BOUND.
      MESSAGE lv_reason TYPE 'S'.
    ELSE.
      " create new repo and add to favorites
      lo_repo_offline = zcl_abapgit_repo_srv=>get_instance( )->new_offline(
        iv_url          = ls_popup-url
        iv_package      = ls_popup-package
        iv_folder_logic = ls_popup-folder_logic
        iv_master_lang_only = ls_popup-master_lang_only ).

      lo_repo_offline->rebuild_local_checksums( ).

      lo_repo ?= lo_repo_offline.

      toggle_favorite( lo_repo->get_key( ) ).
    ENDIF.

    " Set default repo for user
    zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ).

    COMMIT WORK AND WAIT.

  ENDMETHOD.


  METHOD new_online.

    DATA: ls_popup  TYPE zif_abapgit_popups=>ty_popup,
          lo_repo   TYPE REF TO zcl_abapgit_repo,
          lv_reason TYPE string.

    ls_popup = zcl_abapgit_ui_factory=>get_popups( )->repo_popup( iv_url ).
    IF ls_popup-cancel = abap_true.
      RAISE EXCEPTION TYPE zcx_abapgit_cancel.
    ENDIF.

    " make sure package is not already in use for a different repository
    zcl_abapgit_repo_srv=>get_instance( )->get_repo_from_package(
      EXPORTING
        iv_package = ls_popup-package
      IMPORTING
        eo_repo    = lo_repo
        ev_reason  = lv_reason ).

    IF lo_repo IS BOUND.
      MESSAGE lv_reason TYPE 'S'.
    ELSE.
      ro_repo = zcl_abapgit_repo_srv=>get_instance( )->new_online(
        iv_url              = ls_popup-url
        iv_branch_name      = ls_popup-branch_name
        iv_package          = ls_popup-package
        iv_display_name     = ls_popup-display_name
        iv_folder_logic     = ls_popup-folder_logic
        iv_ign_subpkg       = ls_popup-ign_subpkg
        iv_master_lang_only = ls_popup-master_lang_only ).

      toggle_favorite( ro_repo->get_key( ) ).

      lo_repo ?= ro_repo.
    ENDIF.

    " Set default repo for user
    zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ).

    COMMIT WORK.

  ENDMETHOD.
<commit_msg>Fix syntax errors in 702 (#3548)<commit_after>CLASS zcl_abapgit_services_repo DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.

    CLASS-METHODS new_online
      IMPORTING
        !iv_url        TYPE string
      RETURNING
        VALUE(ro_repo) TYPE REF TO zcl_abapgit_repo_online
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS refresh
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS remove
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS purge
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS new_offline
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_attach
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_detach
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS remote_change
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS refresh_local_checksums
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS toggle_favorite
      IMPORTING
        !iv_key TYPE zif_abapgit_persistence=>ty_repo-key
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS open_se80
      IMPORTING
        !iv_package TYPE devclass
      RAISING
        zcx_abapgit_exception .
    CLASS-METHODS transport_to_branch
      IMPORTING
        !iv_repository_key TYPE zif_abapgit_persistence=>ty_value
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS gui_deserialize
      IMPORTING
        !io_repo TYPE REF TO zcl_abapgit_repo
      RAISING
        zcx_abapgit_exception .
  PROTECTED SECTION.
  PRIVATE SECTION.

    CLASS-METHODS popup_overwrite
      CHANGING
        !ct_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt
      RAISING
        zcx_abapgit_exception.
    CLASS-METHODS popup_package_overwrite
      CHANGING
        !ct_overwrite TYPE zif_abapgit_definitions=>ty_overwrite_tt
      RAISING
        zcx_abapgit_exception.
ENDCLASS.



CLASS ZCL_ABAPGIT_SERVICES_REPO IMPLEMENTATION.


  METHOD gui_deserialize.

    DATA: ls_checks       TYPE zif_abapgit_definitions=>ty_deserialize_checks,
          lt_requirements TYPE zif_abapgit_dot_abapgit=>ty_requirement_tt,
          lt_dependencies TYPE zif_abapgit_apack_definitions=>tt_dependencies.


* find troublesome objects
    ls_checks = io_repo->deserialize_checks( ).

* and let the user decide what to do
    TRY.
        popup_overwrite( CHANGING ct_overwrite = ls_checks-overwrite ).
        popup_package_overwrite( CHANGING ct_overwrite = ls_checks-warning_package ).

        IF ls_checks-requirements-met = zif_abapgit_definitions=>gc_no.
          lt_requirements = io_repo->get_dot_abapgit( )->get_data( )-requirements.
          zcl_abapgit_requirement_helper=>requirements_popup( lt_requirements ).
          ls_checks-requirements-decision = zif_abapgit_definitions=>gc_yes.
        ENDIF.

        IF ls_checks-dependencies-met = zif_abapgit_definitions=>gc_no.
          lt_dependencies = io_repo->get_dot_apack( )->get_manifest_descriptor( )-dependencies.
          zcl_abapgit_apack_helper=>dependencies_popup( lt_dependencies ).
        ENDIF.

        IF ls_checks-transport-required = abap_true.
          ls_checks-transport-transport = zcl_abapgit_ui_factory=>get_popups( )->popup_transport_request(
            is_transport_type = ls_checks-transport-type ).
        ENDIF.

      CATCH zcx_abapgit_cancel.
        RETURN.
    ENDTRY.

* and pass decisions to deserialize
    io_repo->deserialize( is_checks = ls_checks
                          ii_log    = io_repo->create_new_log( 'Pull Log' ) ).

  ENDMETHOD.


  METHOD new_offline.

    DATA: ls_popup        TYPE zif_abapgit_popups=>ty_popup,
          lo_repo         TYPE REF TO zcl_abapgit_repo,
          lo_repo_offline TYPE REF TO zcl_abapgit_repo_offline,
          li_repo_srv     TYPE REF TO zif_abapgit_repo_srv,
          lv_reason       TYPE string.

    ls_popup  = zcl_abapgit_ui_factory=>get_popups( )->repo_new_offline( ).
    IF ls_popup-cancel = abap_true.
      RAISE EXCEPTION TYPE zcx_abapgit_cancel.
    ENDIF.

    " make sure package is not already in use for a different repository
    " 702: chaining calls with exp&imp parameters causes syntax error
    li_repo_srv = zcl_abapgit_repo_srv=>get_instance( ).
    li_repo_srv->get_repo_from_package(
      EXPORTING
        iv_package = ls_popup-package
      IMPORTING
        eo_repo    = lo_repo
        ev_reason  = lv_reason ).

    IF lo_repo IS BOUND.
      MESSAGE lv_reason TYPE 'S'.
    ELSE.
      " create new repo and add to favorites
      lo_repo_offline = zcl_abapgit_repo_srv=>get_instance( )->new_offline(
        iv_url          = ls_popup-url
        iv_package      = ls_popup-package
        iv_folder_logic = ls_popup-folder_logic
        iv_master_lang_only = ls_popup-master_lang_only ).

      lo_repo_offline->rebuild_local_checksums( ).

      lo_repo ?= lo_repo_offline.

      toggle_favorite( lo_repo->get_key( ) ).
    ENDIF.

    " Set default repo for user
    zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ).

    COMMIT WORK AND WAIT.

  ENDMETHOD.


  METHOD new_online.

    DATA: ls_popup    TYPE zif_abapgit_popups=>ty_popup,
          lo_repo     TYPE REF TO zcl_abapgit_repo,
          li_repo_srv TYPE REF TO zif_abapgit_repo_srv,
          lv_reason   TYPE string.

    ls_popup = zcl_abapgit_ui_factory=>get_popups( )->repo_popup( iv_url ).
    IF ls_popup-cancel = abap_true.
      RAISE EXCEPTION TYPE zcx_abapgit_cancel.
    ENDIF.

    " make sure package is not already in use for a different repository
    " 702: chaining calls with exp&imp parameters causes syntax error
    li_repo_srv = zcl_abapgit_repo_srv=>get_instance( ).
    li_repo_srv->get_repo_from_package(
      EXPORTING
        iv_package = ls_popup-package
      IMPORTING
        eo_repo    = lo_repo
        ev_reason  = lv_reason ).

    IF lo_repo IS BOUND.
      MESSAGE lv_reason TYPE 'S'.
    ELSE.
      ro_repo = zcl_abapgit_repo_srv=>get_instance( )->new_online(
        iv_url              = ls_popup-url
        iv_branch_name      = ls_popup-branch_name
        iv_package          = ls_popup-package
        iv_display_name     = ls_popup-display_name
        iv_folder_logic     = ls_popup-folder_logic
        iv_ign_subpkg       = ls_popup-ign_subpkg
        iv_master_lang_only = ls_popup-master_lang_only ).

      toggle_favorite( ro_repo->get_key( ) ).

      lo_repo ?= ro_repo.
    ENDIF.

    " Set default repo for user
    zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lo_repo->get_key( ) ).

    COMMIT WORK.

  ENDMETHOD.

{'fraction_non_alphanumeric': 0.05714080356501114, 'fraction_numerical': 0.0012218788183713074, 'mean_word_length': 2.610275038920602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7648493', 'n_tokens_mistral': 5011, 'n_tokens_neox': 4673, 'n_words': 857}