Auto creation of package during new online (#4814)

* Auto creation of package during new online 

If you create a new online repository and the repo does not contain any SAP package, then abapGit will prompt you for the package attributes and create the package for you. This is, for example, the case when you use an newly created online repo as a starting point. 

If the repo does contain a package, then the package will be created automatically when you pull from the repo (as described in [docs](https://docs.abapgit.org/ref-packages.html)).

Closes #4538

* Update docs

Co-authored-by: Lars Hvam <larshp@hotmail.com>
Co-authored-by: Christian Günter <christianguenter@googlemail.com>
This commit is contained in:
Marc Bernard 2021-07-09 15:28:55 +02:00 committed by GitHub
parent bffe75958c
commit 6ff7074aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 20 deletions

View File

@ -16,7 +16,9 @@ If the repository contains sub packages, abapGit will create them automatically
### Automatic Creation of Package
Just enter the name of the SAP package in the "New Online" or "New Offline" dialogs. The package does not have to exist. Then select "Clone Online Repo" or "Create Offline Repo".
Just enter the name of the SAP package in the "New Online" or "New Offline" dialogs. The package does not have to exist. Then select "Create Online Repo" or "Create Offline Repo".
If the online repo does not include any SAP packages, then abapGit will prompt you for the package attributes when you select "Create Online Repo".
### Manually Creation of Package

View File

@ -29,6 +29,12 @@ CLASS zcl_abapgit_repo_online DEFINITION
ALIASES switch_origin
FOR zif_abapgit_repo_online~switch_origin .
METHODS check_and_create_package
IMPORTING
!iv_package TYPE devclass
RAISING
zcx_abapgit_exception .
METHODS get_files_remote
REDEFINITION .
METHODS get_name
@ -71,6 +77,30 @@ ENDCLASS.
CLASS zcl_abapgit_repo_online IMPLEMENTATION.
METHOD check_and_create_package.
DATA ls_item TYPE zif_abapgit_definitions=>ty_item.
DATA lv_package TYPE devclass.
ls_item-obj_type = 'DEVC'.
ls_item-obj_name = iv_package.
IF zcl_abapgit_objects=>exists( ls_item ) = abap_false.
" Check if any package is included in remote
READ TABLE mt_remote TRANSPORTING NO FIELDS
WITH KEY filename = zcl_abapgit_filename_logic=>c_package_file.
IF sy-subrc <> 0.
" If not, prompt to create it
lv_package = zcl_abapgit_services_basis=>create_package( iv_package ).
IF lv_package IS NOT INITIAL.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD fetch_remote.
DATA: li_progress TYPE REF TO zif_abapgit_progress,
@ -163,6 +193,25 @@ CLASS zcl_abapgit_repo_online IMPLEMENTATION.
ENDMETHOD.
METHOD raise_error_if_branch_exists.
DATA:
lt_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt,
lv_display_name TYPE string.
lt_branches = zcl_abapgit_git_transport=>branches( get_url( ) )->get_branches_only( ).
READ TABLE lt_branches WITH TABLE KEY name_key
COMPONENTS name = iv_name
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
lv_display_name = zcl_abapgit_git_branch_list=>get_display_name( iv_name ).
zcx_abapgit_exception=>raise( |Branch '{ lv_display_name }' already exists| ).
ENDIF.
ENDMETHOD.
METHOD set_objects.
mt_objects = it_objects.
ENDMETHOD.
@ -331,23 +380,4 @@ CLASS zcl_abapgit_repo_online IMPLEMENTATION.
ENDIF.
ENDMETHOD.
METHOD raise_error_if_branch_exists.
DATA:
lt_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt,
lv_display_name TYPE string.
lt_branches = zcl_abapgit_git_transport=>branches( get_url( ) )->get_branches_only( ).
READ TABLE lt_branches WITH TABLE KEY name_key
COMPONENTS name = iv_name
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
lv_display_name = zcl_abapgit_git_branch_list=>get_display_name( iv_name ).
zcx_abapgit_exception=>raise( |Branch '{ lv_display_name }' already exists| ).
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@ -501,6 +501,7 @@ CLASS zcl_abapgit_repo_srv IMPLEMENTATION.
ro_repo->refresh( ).
ro_repo->find_remote_dot_abapgit( ).
ro_repo->check_and_create_package( iv_package ).
ENDMETHOD.