utils: allow repo names with dots (#4428)

There is no problem with having dots in names - we have these names in
our corporate github.

I don't know how to deal with the non-deterministic regex differently
than first trying with the suffix .git and than without it.

Closes #4427
This commit is contained in:
Jakub Filak 2021-01-20 12:31:43 +01:00 committed by GitHub
parent 31a550db0f
commit ad0c8cd12e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View File

@ -119,10 +119,14 @@ CLASS zcl_abapgit_url IMPLEMENTATION.
METHOD regex.
FIND REGEX '(https?://[^/]*)(.*/)([^\.]*)[\.git]?' IN iv_url
FIND REGEX '(https?://[^/]*)(.*/)(.*)\.git$' IN iv_url
SUBMATCHES ev_host ev_path ev_name.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( 'Malformed URL' ).
FIND REGEX '(https?://[^/]*)(.*/)(.*)$' IN iv_url
SUBMATCHES ev_host ev_path ev_name.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( 'Malformed URL' ).
ENDIF.
ENDIF.
ENDMETHOD.

View File

@ -13,6 +13,8 @@ CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
repo_address2 FOR TESTING RAISING zcx_abapgit_exception,
repo_address3 FOR TESTING RAISING zcx_abapgit_exception,
repo_address4 FOR TESTING RAISING zcx_abapgit_exception,
repo_address5_dots FOR TESTING RAISING zcx_abapgit_exception,
repo_address6_dots_and_git FOR TESTING RAISING zcx_abapgit_exception,
repo_error FOR TESTING,
url_validate1 FOR TESTING,
url_validate2 FOR TESTING,
@ -157,6 +159,33 @@ CLASS ltcl_test IMPLEMENTATION.
ENDMETHOD.
METHOD repo_address5_dots.
DATA:
lv_url_address TYPE string.
lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/jfilak/abap.awesome.app1' ).
cl_abap_unit_assert=>assert_equals(
exp = 'https://github.com/jfilak/abap.awesome.app1'
act = lv_url_address ).
ENDMETHOD.
METHOD repo_address6_dots_and_git.
DATA:
lv_url_address TYPE string.
lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/jfilak/abap.awesome.app1.git' ).
cl_abap_unit_assert=>assert_equals(
exp = 'https://github.com/jfilak/abap.awesome.app1'
act = lv_url_address ).
ENDMETHOD.
METHOD url_validate1.
TRY.