Refresh online repo: call BRANCH_LIST just once

Before this commit is applied BRANCH_LIST is called twice while
refreshing an online repo. This leads to two identical HTTP calls.
After this commit is applied BRANCH_LIST is only called once and
therefore only one HTTP request is sent.
This commit is contained in:
Christian Guenter 2018-07-22 10:32:33 +00:00 committed by Lars Hvam
parent d7e90aae60
commit bb82f2c8bd
3 changed files with 28 additions and 20 deletions

View File

@ -11,6 +11,7 @@ CLASS zcl_abapgit_git_porcelain DEFINITION
!et_files TYPE zif_abapgit_definitions=>ty_files_tt !et_files TYPE zif_abapgit_definitions=>ty_files_tt
!et_objects TYPE zif_abapgit_definitions=>ty_objects_tt !et_objects TYPE zif_abapgit_definitions=>ty_objects_tt
!ev_branch TYPE zif_abapgit_definitions=>ty_sha1 !ev_branch TYPE zif_abapgit_definitions=>ty_sha1
!eo_branch_list TYPE REF TO zcl_abapgit_git_branch_list
RAISING RAISING
zcx_abapgit_exception . zcx_abapgit_exception .
CLASS-METHODS push CLASS-METHODS push
@ -351,6 +352,7 @@ CLASS zcl_abapgit_git_porcelain IMPLEMENTATION.
CLEAR et_files. CLEAR et_files.
CLEAR et_objects. CLEAR et_objects.
CLEAR ev_branch. CLEAR ev_branch.
CLEAR eo_branch_list.
zcl_abapgit_git_transport=>upload_pack( zcl_abapgit_git_transport=>upload_pack(
EXPORTING EXPORTING
@ -358,7 +360,8 @@ CLASS zcl_abapgit_git_porcelain IMPLEMENTATION.
iv_branch_name = io_repo->get_branch_name( ) iv_branch_name = io_repo->get_branch_name( )
IMPORTING IMPORTING
et_objects = et_objects et_objects = et_objects
ev_branch = ev_branch ). ev_branch = ev_branch
eo_branch_list = eo_branch_list ).
READ TABLE et_objects INTO ls_object WITH KEY sha1 = ev_branch type = zif_abapgit_definitions=>gc_type-commit. READ TABLE et_objects INTO ls_object WITH KEY sha1 = ev_branch type = zif_abapgit_definitions=>gc_type-commit.
IF sy-subrc <> 0. IF sy-subrc <> 0.

View File

@ -12,6 +12,7 @@ CLASS zcl_abapgit_git_transport DEFINITION
it_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt OPTIONAL it_branches TYPE zif_abapgit_definitions=>ty_git_branch_list_tt OPTIONAL
EXPORTING et_objects TYPE zif_abapgit_definitions=>ty_objects_tt EXPORTING et_objects TYPE zif_abapgit_definitions=>ty_objects_tt
ev_branch TYPE zif_abapgit_definitions=>ty_sha1 ev_branch TYPE zif_abapgit_definitions=>ty_sha1
eo_branch_list TYPE REF TO zcl_abapgit_git_branch_list
RAISING zcx_abapgit_exception. RAISING zcx_abapgit_exception.
* local to remote * local to remote
@ -46,6 +47,7 @@ CLASS zcl_abapgit_git_transport DEFINITION
iv_branch_name TYPE string iv_branch_name TYPE string
EXPORTING eo_client TYPE REF TO zcl_abapgit_http_client EXPORTING eo_client TYPE REF TO zcl_abapgit_http_client
ev_branch TYPE zif_abapgit_definitions=>ty_sha1 ev_branch TYPE zif_abapgit_definitions=>ty_sha1
eo_branch_list TYPE REF TO zcl_abapgit_git_branch_list
RAISING zcx_abapgit_exception. RAISING zcx_abapgit_exception.
CLASS-METHODS parse CLASS-METHODS parse
@ -98,18 +100,16 @@ CLASS zcl_abapgit_git_transport IMPLEMENTATION.
METHOD find_branch. METHOD find_branch.
DATA: lo_branch_list TYPE REF TO zcl_abapgit_git_branch_list.
branch_list( branch_list(
EXPORTING EXPORTING
iv_url = iv_url iv_url = iv_url
iv_service = iv_service iv_service = iv_service
IMPORTING IMPORTING
eo_client = eo_client eo_client = eo_client
eo_branch_list = lo_branch_list ). eo_branch_list = eo_branch_list ).
IF ev_branch IS SUPPLIED. IF ev_branch IS SUPPLIED.
ev_branch = lo_branch_list->find_by_name( iv_branch_name )-sha1. ev_branch = eo_branch_list->find_by_name( iv_branch_name )-sha1.
ENDIF. ENDIF.
ENDMETHOD. "find_branch ENDMETHOD. "find_branch
@ -229,7 +229,9 @@ CLASS zcl_abapgit_git_transport IMPLEMENTATION.
FIELD-SYMBOLS: <ls_branch> LIKE LINE OF lt_branches. FIELD-SYMBOLS: <ls_branch> LIKE LINE OF lt_branches.
CLEAR et_objects. CLEAR: et_objects,
ev_branch,
eo_branch_list.
find_branch( find_branch(
EXPORTING EXPORTING
@ -238,6 +240,7 @@ CLASS zcl_abapgit_git_transport IMPLEMENTATION.
iv_branch_name = iv_branch_name iv_branch_name = iv_branch_name
IMPORTING IMPORTING
eo_client = lo_client eo_client = lo_client
eo_branch_list = eo_branch_list
ev_branch = ev_branch ). ev_branch = ev_branch ).
IF it_branches IS INITIAL. IF it_branches IS INITIAL.

View File

@ -91,7 +91,6 @@ CLASS zcl_abapgit_repo_online DEFINITION
DATA mt_objects TYPE zif_abapgit_definitions=>ty_objects_tt . DATA mt_objects TYPE zif_abapgit_definitions=>ty_objects_tt .
DATA mv_branch TYPE zif_abapgit_definitions=>ty_sha1 . DATA mv_branch TYPE zif_abapgit_definitions=>ty_sha1 .
DATA mv_initialized TYPE abap_bool . DATA mv_initialized TYPE abap_bool .
DATA mo_branches TYPE REF TO zcl_abapgit_git_branch_list .
DATA mt_status TYPE zif_abapgit_definitions=>ty_results_tt . DATA mt_status TYPE zif_abapgit_definitions=>ty_results_tt .
DATA mv_code_inspector_successful TYPE abap_bool . DATA mv_code_inspector_successful TYPE abap_bool .
@ -101,6 +100,8 @@ CLASS zcl_abapgit_repo_online DEFINITION
RAISING RAISING
zcx_abapgit_exception . zcx_abapgit_exception .
METHODS actualize_head_branch METHODS actualize_head_branch
IMPORTING
io_branch_list TYPE REF TO zcl_abapgit_git_branch_list
RAISING RAISING
zcx_abapgit_exception . zcx_abapgit_exception .
ENDCLASS. ENDCLASS.
@ -112,7 +113,7 @@ CLASS ZCL_ABAPGIT_REPO_ONLINE IMPLEMENTATION.
METHOD actualize_head_branch. METHOD actualize_head_branch.
DATA lv_branch_name TYPE string. DATA lv_branch_name TYPE string.
lv_branch_name = mo_branches->get_head( )-name. lv_branch_name = io_branch_list->get_head( )-name.
IF lv_branch_name <> ms_data-head_branch. IF lv_branch_name <> ms_data-head_branch.
set( iv_head_branch = lv_branch_name ). set( iv_head_branch = lv_branch_name ).
@ -363,7 +364,8 @@ CLASS ZCL_ABAPGIT_REPO_ONLINE IMPLEMENTATION.
METHOD refresh. METHOD refresh.
DATA: lo_progress TYPE REF TO zcl_abapgit_progress, DATA: lo_progress TYPE REF TO zcl_abapgit_progress,
lx_exception TYPE REF TO zcx_abapgit_exception. lx_exception TYPE REF TO zcx_abapgit_exception,
lo_branch_list TYPE REF TO zcl_abapgit_git_branch_list.
super->refresh( iv_drop_cache ). super->refresh( iv_drop_cache ).
reset_status( ). reset_status( ).
@ -381,10 +383,10 @@ CLASS ZCL_ABAPGIT_REPO_ONLINE IMPLEMENTATION.
IMPORTING IMPORTING
et_files = mt_remote et_files = mt_remote
et_objects = mt_objects et_objects = mt_objects
ev_branch = mv_branch ). ev_branch = mv_branch
eo_branch_list = lo_branch_list ).
mo_branches = zcl_abapgit_git_transport=>branches( get_url( ) ). actualize_head_branch( lo_branch_list ).
actualize_head_branch( ).
mv_initialized = abap_true. mv_initialized = abap_true.