PR ENUM: fix for private repos (#6592)

This commit is contained in:
Lars Hvam 2023-10-30 14:31:35 +01:00 committed by GitHub
parent bb18b71f52
commit e7371c8f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,6 +61,8 @@ CLASS ZCL_ABAPGIT_PR_ENUM_GITHUB IMPLEMENTATION.
METHOD constructor.
DATA lv_search TYPE string.
mv_repo_url = |https://api.github.com/repos/{ iv_user_and_repo }|.
mi_http_agent = ii_http_agent.
mi_http_agent->global_headers( )->set(
@ -71,6 +73,16 @@ CLASS ZCL_ABAPGIT_PR_ENUM_GITHUB IMPLEMENTATION.
mi_http_agent->global_headers( )->set(
iv_key = 'Authorization'
iv_val = zcl_abapgit_login_manager=>get( mv_repo_url ) ).
ELSE.
* fallback, try searching for the git credentials
lv_search = mv_repo_url.
REPLACE FIRST OCCURRENCE OF 'api.github.com/repos' IN lv_search WITH 'github.com'.
IF zcl_abapgit_login_manager=>get( lv_search ) IS NOT INITIAL.
mi_http_agent->global_headers( )->set(
iv_key = 'Authorization'
iv_val = zcl_abapgit_login_manager=>get( lv_search ) ).
ENDIF.
ENDIF.
ENDMETHOD.