mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
Simplify Ignore Logic (#3996)
* Simplify Ignore Logic Closes https://github.com/abapGit/abapGit/issues/3675 * Update docs regaring ignore logic Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
f6ad8c668d
commit
1c8c216a5c
|
@ -92,6 +92,8 @@ The folder logic FULL forces the installation of a repository into packages with
|
|||
Files which abapGit will not download to your ABAP system. Typically, this includes references to readme, changelog, and license
|
||||
files as well as repository configuration related to workflows like build or linting jobs.
|
||||
|
||||
Assuming that default starting folder /src/ is used, any files in root / or any other folder than the starting folder are ignored automatically. Therefore it will not be necessary to list files of the root folder into the ignore list (and as a consequence, the default ignore list is empty).
|
||||
|
||||
## Requirements
|
||||
|
||||
In this section, you can specify the minimum requirements that should be fulfilled to allow installation of the repository. Listed software components should exist in the target system and be at the given release or higher. If the target system matches the minimum release, then it must also be at the given patch level or higher.
|
||||
|
|
|
@ -120,16 +120,6 @@ CLASS ZCL_ABAPGIT_DOT_ABAPGIT IMPLEMENTATION.
|
|||
ls_data-starting_folder = '/src/'.
|
||||
ls_data-folder_logic = zif_abapgit_dot_abapgit=>c_folder_logic-prefix.
|
||||
|
||||
APPEND '/.gitignore' TO ls_data-ignore.
|
||||
APPEND '/LICENSE' TO ls_data-ignore.
|
||||
APPEND '/README.md' TO ls_data-ignore.
|
||||
APPEND '/package.json' TO ls_data-ignore.
|
||||
APPEND '/.travis.yml' TO ls_data-ignore.
|
||||
APPEND '/.gitlab-ci.yml' TO ls_data-ignore.
|
||||
APPEND '/abaplint.json' TO ls_data-ignore.
|
||||
APPEND '/azure-pipelines.yml' TO ls_data-ignore.
|
||||
APPEND '/.devcontainer.json' TO ls_data-ignore.
|
||||
|
||||
CREATE OBJECT ro_dot_abapgit
|
||||
EXPORTING
|
||||
is_data = ls_data.
|
||||
|
@ -225,21 +215,30 @@ CLASS ZCL_ABAPGIT_DOT_ABAPGIT IMPLEMENTATION.
|
|||
lv_name = iv_path && iv_filename.
|
||||
|
||||
CONCATENATE ms_data-starting_folder '*' INTO lv_starting.
|
||||
|
||||
" Always allow .abapgit.xml and .apack-manifest.xml
|
||||
CONCATENATE '/' zif_abapgit_definitions=>c_dot_abapgit INTO lv_dot.
|
||||
IF lv_name = lv_dot.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
CONCATENATE '/' zif_abapgit_apack_definitions=>c_dot_apack_manifest INTO lv_dot.
|
||||
IF lv_name = lv_dot.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
" Ignore all files matching pattern in ignore list
|
||||
LOOP AT ms_data-ignore INTO lv_ignore.
|
||||
FIND ALL OCCURRENCES OF '/' IN lv_name MATCH COUNT lv_count.
|
||||
|
||||
IF lv_name CP lv_ignore
|
||||
OR ( ms_data-starting_folder <> '/'
|
||||
AND lv_count > 1
|
||||
AND NOT lv_name CP lv_starting
|
||||
AND NOT lv_name = lv_dot ).
|
||||
IF lv_name CP lv_ignore.
|
||||
rv_ignored = abap_true.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
" Ignore all files outside of starting folder tree
|
||||
IF ms_data-starting_folder <> '/' AND NOT lv_name CP lv_starting.
|
||||
rv_ignored = abap_true.
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ CLASS ltcl_dot_abapgit IMPLEMENTATION.
|
|||
|
||||
METHOD ignore.
|
||||
|
||||
CONSTANTS: lc_path TYPE string VALUE '/',
|
||||
CONSTANTS: lc_path TYPE string VALUE '/src/',
|
||||
lc_root TYPE string VALUE '/',
|
||||
lc_filename TYPE string VALUE 'foobar.txt'.
|
||||
|
||||
DATA: lv_ignored TYPE abap_bool,
|
||||
|
@ -44,12 +45,14 @@ CLASS ltcl_dot_abapgit IMPLEMENTATION.
|
|||
|
||||
lo_dot = zcl_abapgit_dot_abapgit=>build_default( ).
|
||||
|
||||
" Any file in default starting folder /src/ should not be ignored
|
||||
lv_ignored = lo_dot->is_ignored( iv_path = lc_path
|
||||
iv_filename = lc_filename ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_ignored
|
||||
exp = abap_false ).
|
||||
|
||||
" Add file to ignore list -> expect to be ignored
|
||||
lo_dot->add_ignore( iv_path = lc_path
|
||||
iv_filename = lc_filename ).
|
||||
|
||||
|
@ -59,6 +62,7 @@ CLASS ltcl_dot_abapgit IMPLEMENTATION.
|
|||
act = lv_ignored
|
||||
exp = abap_true ).
|
||||
|
||||
" Remove file from ignore list -> expect to be allowed
|
||||
lo_dot->remove_ignore( iv_path = lc_path
|
||||
iv_filename = lc_filename ).
|
||||
|
||||
|
@ -68,6 +72,33 @@ CLASS ltcl_dot_abapgit IMPLEMENTATION.
|
|||
act = lv_ignored
|
||||
exp = abap_false ).
|
||||
|
||||
" .abapgit.xml and .apack-manifest.xml must always be allowed
|
||||
lv_ignored = lo_dot->is_ignored( iv_path = lc_root
|
||||
iv_filename = zif_abapgit_definitions=>c_dot_abapgit ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_ignored
|
||||
exp = abap_false ).
|
||||
|
||||
lv_ignored = lo_dot->is_ignored( iv_path = lc_root
|
||||
iv_filename = zif_abapgit_apack_definitions=>c_dot_apack_manifest ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_ignored
|
||||
exp = abap_false ).
|
||||
|
||||
" File in root must be ignored since it's not under starting folder
|
||||
lv_ignored = lo_dot->is_ignored( iv_path = lc_root
|
||||
iv_filename = 'abaplint.json' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_ignored
|
||||
exp = abap_true ).
|
||||
|
||||
" File under starting folder must not be ignored
|
||||
lv_ignored = lo_dot->is_ignored( iv_path = lc_path
|
||||
iv_filename = 'ztest.prog.abap' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
act = lv_ignored
|
||||
exp = abap_false ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user