Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_repo_content_list DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. METHODS constructor IMPORTING io_repo TYPE REF TO zcl_abapgit_repo. METHODS list IMPORTING iv_path TYPE string iv_by_folders TYPE abap_bool OPTIONAL iv_changes_only TYPE abap_bool OPTIONAL iv_transports TYPE abap_bool OPTIONAL RETURNING VALUE(rt_repo_items) TYPE zif_abapgit_definitions=>ty_repo_item_tt RAISING zcx_abapgit_exception. METHODS get_log RETURNING VALUE(ri_log) TYPE REF TO zif_abapgit_log. PROTECTED SECTION. PRIVATE SECTION. CONSTANTS: BEGIN OF c_sortkey, default TYPE i VALUE 9999, parent_dir TYPE i VALUE 0, dir TYPE i VALUE 1, orphan TYPE i VALUE 2, changed TYPE i VALUE 3, inactive TYPE i VALUE 4, END OF c_sortkey. DATA: mo_repo TYPE REF TO zcl_abapgit_repo, mi_log TYPE REF TO zif_abapgit_log. METHODS build_repo_items RETURNING VALUE(rt_repo_items) TYPE zif_abapgit_definitions=>ty_repo_item_tt RAISING zcx_abapgit_exception. METHODS build_folders IMPORTING iv_cur_dir TYPE string CHANGING ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt RAISING zcx_abapgit_exception. METHODS determine_transports CHANGING ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt. METHODS filter_changes CHANGING ct_repo_items TYPE zif_abapgit_definitions=>ty_repo_item_tt. METHODS check_repo_size RAISING zcx_abapgit_exception . ENDCLASS. CLASS zcl_abapgit_repo_content_list IMPLEMENTATION. METHOD build_folders. DATA: lv_index TYPE i, lt_subitems LIKE ct_repo_items, ls_subitem LIKE LINE OF ct_repo_items, ls_folder LIKE LINE OF ct_repo_items. DATA lo_state TYPE REF TO zcl_abapgit_repo_item_state. FIELD-SYMBOLS <ls_item> LIKE LINE OF ct_repo_items. LOOP AT ct_repo_items ASSIGNING <ls_item>. lv_index = sy-tabix. CHECK <ls_item>-path <> iv_cur_dir. " files in target dir - just leave them be IF zcl_abapgit_path=>is_subdir( iv_path = <ls_item>-path iv_parent = iv_cur_dir ) = abap_true. ls_subitem-changes = <ls_item>-changes. ls_subitem-path = <ls_item>-path. ls_subitem-lstate = <ls_item>-lstate. ls_subitem-rstate = <ls_item>-rstate. APPEND ls_subitem TO lt_subitems. ENDIF. DELETE ct_repo_items INDEX lv_index. ENDLOOP. SORT lt_subitems BY path ASCENDING. LOOP AT lt_subitems ASSIGNING <ls_item>. AT NEW path. CLEAR ls_folder. ls_folder-path = <ls_item>-path. ls_folder-sortkey = c_sortkey-dir. " Directory ls_folder-is_dir = abap_true. CREATE OBJECT lo_state. ENDAT. ls_folder-changes = ls_folder-changes + <ls_item>-changes. lo_state->sum_with_repo_item( <ls_item> ). AT END OF path. ls_folder-lstate = lo_state->local( ). ls_folder-rstate = lo_state->remote( ). APPEND ls_folder TO ct_repo_items. ENDAT. ENDLOOP. ENDMETHOD. METHOD build_repo_items. DATA: lo_state TYPE REF TO zcl_abapgit_repo_item_state, ls_file TYPE zif_abapgit_definitions=>ty_repo_file, lt_status TYPE zif_abapgit_definitions=>ty_results_tt, ls_item TYPE zif_abapgit_definitions=>ty_item, ls_previous LIKE ls_item, lv_changed_by TYPE string. FIELD-SYMBOLS: <ls_status> LIKE LINE OF lt_status, <ls_repo_item> LIKE LINE OF rt_repo_items. lt_status = zcl_abapgit_repo_status=>calculate( ii_repo = mo_repo ii_log = mi_log ). LOOP AT lt_status ASSIGNING <ls_status>. AT NEW obj_name. "obj_type + obj_name APPEND INITIAL LINE TO rt_repo_items ASSIGNING <ls_repo_item>. <ls_repo_item>-obj_type = <ls_status>-obj_type. <ls_repo_item>-obj_name = <ls_status>-obj_name. <ls_repo_item>-inactive = <ls_status>-inactive. <ls_repo_item>-sortkey = c_sortkey-default. " Default sort key <ls_repo_item>-changes = 0. <ls_repo_item>-path = <ls_status>-path. <ls_repo_item>-srcsystem = <ls_status>-srcsystem. CREATE OBJECT lo_state. ENDAT. IF <ls_status>-filename IS NOT INITIAL. MOVE-CORRESPONDING <ls_status> TO ls_file. ls_file-is_changed = boolc( <ls_status>-match = abap_false ). " TODO refactor APPEND ls_file TO <ls_repo_item>-files. IF <ls_status>-inactive = abap_true AND <ls_repo_item>-sortkey > c_sortkey-changed. <ls_repo_item>-sortkey = c_sortkey-inactive. ENDIF. IF ls_file-is_changed = abap_true. <ls_repo_item>-sortkey = c_sortkey-changed. " Changed files <ls_repo_item>-changes = <ls_repo_item>-changes + 1. lo_state->sum_with_status_item( <ls_status> ). ENDIF. ENDIF. IF <ls_repo_item>-changes > 0 AND <ls_repo_item>-obj_type IS NOT INITIAL. MOVE-CORRESPONDING <ls_repo_item> TO ls_item. IF ls_previous = ls_item. <ls_repo_item>-changed_by = lv_changed_by. ELSEIF zcl_abapgit_objects=>exists( ls_item ) = abap_true. <ls_repo_item>-changed_by = zcl_abapgit_objects=>changed_by( ls_item ). ls_previous = ls_item. lv_changed_by = <ls_repo_item>-changed_by. ENDIF. CLEAR ls_item. ENDIF. AT END OF obj_name. "obj_type + obj_name IF <ls_repo_item>-obj_type IS INITIAL. <ls_repo_item>-sortkey = c_sortkey-orphan. "Virtual objects ENDIF. <ls_repo_item>-lstate = lo_state->local( ). <ls_repo_item>-rstate = lo_state->remote( ). <ls_repo_item>-packmove = lo_state->is_reassigned( ). ENDAT. ENDLOOP. ENDMETHOD. METHOD check_repo_size. CONSTANTS lc_new_repo_size TYPE i VALUE 10. DATA lt_remote TYPE zif_abapgit_git_definitions=>ty_files_tt. lt_remote = mo_repo->get_files_remote( ). IF lines( lt_remote ) > lc_new_repo_size. " Less files means it's a new repo (with just readme and license, for example) which is ok READ TABLE lt_remote TRANSPORTING NO FIELDS WITH KEY file_path COMPONENTS path = zif_abapgit_definitions=>c_root_dir filename = zif_abapgit_definitions=>c_dot_abapgit. IF sy-subrc <> 0. mi_log->add_warning( |Cannot find .abapgit.xml - Is this an abapGit repository?| ). ENDIF. ENDIF. ENDMETHOD. METHOD constructor. mo_repo = io_repo. CREATE OBJECT mi_log TYPE zcl_abapgit_log. ENDMETHOD. METHOD determine_transports. DATA ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS <ls_item> LIKE LINE OF ct_repo_items. LOOP AT ct_repo_items ASSIGNING <ls_item>. ls_item-obj_type = <ls_item>-obj_type. ls_item-obj_name = <ls_item>-obj_name. TRY. <ls_item>-transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ). CATCH zcx_abapgit_exception ##NO_HANDLER. " Ignore errors related to object check when trying to get transport ENDTRY. ENDLOOP. ENDMETHOD. METHOD filter_changes. FIELD-SYMBOLS: <ls_item> TYPE zif_abapgit_definitions=>ty_repo_item. DELETE ct_repo_items WHERE changes = 0 AND inactive = abap_false. LOOP AT ct_repo_items ASSIGNING <ls_item> WHERE inactive = abap_false. DELETE <ls_item>-files WHERE is_changed = abap_false. ENDLOOP. ENDMETHOD. METHOD get_log. DATA li_repo_log TYPE REF TO zif_abapgit_log. DATA lt_repo_msg TYPE zif_abapgit_log=>ty_log_outs. DATA lr_repo_msg TYPE REF TO zif_abapgit_log=>ty_log_out. ri_log = mi_log. "add warning and error messages from repo log li_repo_log = mo_repo->get_log( ). IF li_repo_log IS BOUND. lt_repo_msg = li_repo_log->get_messages( ). LOOP AT lt_repo_msg REFERENCE INTO lr_repo_msg WHERE type CA 'EW'. CASE lr_repo_msg->type. WHEN 'E'. ri_log->add_error( lr_repo_msg->text ). WHEN 'W'. ri_log->add_warning( lr_repo_msg->text ). WHEN OTHERS. CONTINUE. ENDCASE. ENDLOOP. ENDIF. ENDMETHOD. METHOD list. FIELD-SYMBOLS <ls_repo_item> LIKE LINE OF rt_repo_items. mi_log->clear( ). rt_repo_items = build_repo_items( ). check_repo_size( ). IF mo_repo->has_remote_source( ) = abap_false. " If there's no remote source, ignore the item state LOOP AT rt_repo_items ASSIGNING <ls_repo_item>. CLEAR: <ls_repo_item>-changes, <ls_repo_item>-lstate, <ls_repo_item>-rstate. ENDLOOP. ENDIF. IF iv_by_folders = abap_true. build_folders( EXPORTING iv_cur_dir = iv_path CHANGING ct_repo_items = rt_repo_items ). ENDIF. IF iv_changes_only = abap_true. " There are never changes for offline repositories filter_changes( CHANGING ct_repo_items = rt_repo_items ). ENDIF. IF iv_transports = abap_true. determine_transports( CHANGING ct_repo_items = rt_repo_items ). ENDIF. SORT rt_repo_items BY sortkey ASCENDING path ASCENDING obj_name ASCENDING. ENDMETHOD. ENDCLASS. |