abapgit-agent 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +4 -4
- package/README.md +3 -1
- package/abap/zcl_abgagt_agent.clas.abap +0 -349
- package/abap/zcl_abgagt_cmd_factory.clas.abap +3 -1
- package/abap/zcl_abgagt_command_create.clas.abap +86 -0
- package/abap/zcl_abgagt_command_create.clas.xml +15 -0
- package/abap/zcl_abgagt_command_import.clas.abap +138 -0
- package/abap/zcl_abgagt_command_import.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_create.clas.abap +70 -0
- package/abap/zcl_abgagt_resource_create.clas.xml +15 -0
- package/abap/zcl_abgagt_resource_import.clas.abap +66 -0
- package/abap/zcl_abgagt_resource_import.clas.xml +15 -0
- package/abap/zcl_abgagt_rest_handler.clas.abap +2 -0
- package/abap/zif_abgagt_agent.intf.abap +3 -84
- package/abap/zif_abgagt_command.intf.abap +3 -1
- package/bin/abapgit-agent +325 -16
- package/docs/commands.md +107 -0
- package/docs/create-command.md +211 -0
- package/docs/health-command.md +89 -0
- package/docs/import-command.md +196 -0
- package/docs/init-command.md +176 -0
- package/docs/inspect-command.md +158 -0
- package/docs/pull-command.md +188 -0
- package/docs/status-command.md +68 -0
- package/docs/unit-command.md +167 -0
- package/package.json +1 -1
- package/src/abap-client.js +60 -0
- package/src/agent.js +52 -0
package/INSTALL.md
CHANGED
|
@@ -62,11 +62,11 @@ Deploy ABAP objects using abapGit:
|
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
64
|
# Option A: Install globally for system-level integration
|
|
65
|
-
sudo npm
|
|
65
|
+
sudo npm install -g abapgit-agent
|
|
66
66
|
|
|
67
|
-
# Option B:
|
|
67
|
+
# Option B: For local development, use npm link instead
|
|
68
68
|
cd abapgit-agent
|
|
69
|
-
npm
|
|
69
|
+
sudo npm link
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
## Configuration
|
|
@@ -100,7 +100,7 @@ cp .abapGitAgent.example .abapGitAgent
|
|
|
100
100
|
|
|
101
101
|
This package supports **system-level integration**, meaning any ABAP git repository can use it without cloning this repository:
|
|
102
102
|
|
|
103
|
-
1. **Install globally**: `sudo npm
|
|
103
|
+
1. **Install globally**: `sudo npm install -g abapgit-agent`
|
|
104
104
|
2. **Configure**: Add `.abapGitAgent` to your ABAP repo
|
|
105
105
|
3. **Use**: Run `abapgit-agent` from your repo directory
|
|
106
106
|
|
package/README.md
CHANGED
|
@@ -14,7 +14,8 @@ This project provides a bridge between AI coding tools and your ABAP system:
|
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
|
-
1. **Install CLI**:
|
|
17
|
+
1. **Install CLI**: Run `sudo npm install -g abapgit-agent`
|
|
18
|
+
- For local development, use `sudo npm link` from this repo instead
|
|
18
19
|
2. **Configure repo**: Add `.abapGitAgent` with SAP credentials
|
|
19
20
|
3. **Validate code**: Run `abapgit-agent pull` after pushing
|
|
20
21
|
|
|
@@ -111,6 +112,7 @@ Failure case with details:
|
|
|
111
112
|
| Topic | File |
|
|
112
113
|
|-------|------|
|
|
113
114
|
| Installation & Setup | [INSTALL.md](INSTALL.md) |
|
|
115
|
+
| CLI Commands Overview | [docs/commands.md](docs/commands.md) |
|
|
114
116
|
| REST API Reference | [API.md](API.md) |
|
|
115
117
|
| Error Handling | [ERROR_HANDLING.md](ERROR_HANDLING.md) |
|
|
116
118
|
| ABAP Coding Guidelines | [abap/CLAUDE.md](abap/CLAUDE.md) |
|
|
@@ -62,25 +62,6 @@ CLASS zcl_abgagt_agent DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
|
62
62
|
RETURNING
|
|
63
63
|
VALUE(rs_result) TYPE zif_abgagt_agent=>ty_result.
|
|
64
64
|
|
|
65
|
-
METHODS get_test_classes
|
|
66
|
-
IMPORTING
|
|
67
|
-
iv_package TYPE devclass OPTIONAL
|
|
68
|
-
it_objects TYPE zif_abgagt_agent=>ty_object_keys OPTIONAL
|
|
69
|
-
RETURNING
|
|
70
|
-
VALUE(rt_classes) TYPE zif_abgagt_agent=>ty_object_keys.
|
|
71
|
-
|
|
72
|
-
METHODS run_aunit_tests
|
|
73
|
-
IMPORTING
|
|
74
|
-
it_classes TYPE zif_abgagt_agent=>ty_object_keys
|
|
75
|
-
RETURNING
|
|
76
|
-
VALUE(rt_results) TYPE zif_abgagt_agent=>ty_test_results.
|
|
77
|
-
|
|
78
|
-
METHODS count_results
|
|
79
|
-
IMPORTING
|
|
80
|
-
it_results TYPE zif_abgagt_agent=>ty_test_results
|
|
81
|
-
CHANGING
|
|
82
|
-
rs_stats TYPE zif_abgagt_agent=>ty_unit_result.
|
|
83
|
-
|
|
84
65
|
ENDCLASS.
|
|
85
66
|
|
|
86
67
|
CLASS zcl_abgagt_agent IMPLEMENTATION.
|
|
@@ -182,179 +163,6 @@ CLASS zcl_abgagt_agent IMPLEMENTATION.
|
|
|
182
163
|
ENDIF.
|
|
183
164
|
ENDMETHOD.
|
|
184
165
|
|
|
185
|
-
METHOD zif_abgagt_agent~inspect.
|
|
186
|
-
DATA ls_error LIKE LINE OF rs_result-errors.
|
|
187
|
-
DATA lv_obj_type TYPE string.
|
|
188
|
-
DATA lv_obj_name TYPE string.
|
|
189
|
-
|
|
190
|
-
" Convert file name to object type and name
|
|
191
|
-
parse_file_to_object(
|
|
192
|
-
EXPORTING iv_file = iv_file
|
|
193
|
-
IMPORTING ev_obj_type = lv_obj_type
|
|
194
|
-
ev_obj_name = lv_obj_name ).
|
|
195
|
-
|
|
196
|
-
rs_result-success = abap_true.
|
|
197
|
-
rs_result-object_type = lv_obj_type.
|
|
198
|
-
rs_result-object_name = lv_obj_name.
|
|
199
|
-
|
|
200
|
-
TRY.
|
|
201
|
-
" Check if object exists in TADIR
|
|
202
|
-
DATA lv_devclass TYPE devclass.
|
|
203
|
-
SELECT SINGLE devclass FROM tadir
|
|
204
|
-
INTO lv_devclass
|
|
205
|
-
WHERE pgmid = 'R3TR'
|
|
206
|
-
AND object = lv_obj_type
|
|
207
|
-
AND obj_name = lv_obj_name.
|
|
208
|
-
|
|
209
|
-
IF lv_devclass IS INITIAL.
|
|
210
|
-
rs_result-success = abap_false.
|
|
211
|
-
rs_result-error_count = 1.
|
|
212
|
-
ls_error-line = '1'.
|
|
213
|
-
ls_error-column = '1'.
|
|
214
|
-
ls_error-text = |Object { lv_obj_type } { lv_obj_name } does not exist|.
|
|
215
|
-
ls_error-word = ''.
|
|
216
|
-
APPEND ls_error TO rs_result-errors.
|
|
217
|
-
RETURN.
|
|
218
|
-
ENDIF.
|
|
219
|
-
|
|
220
|
-
" Create object structure for the specific object
|
|
221
|
-
DATA ls_obj TYPE scir_objs.
|
|
222
|
-
ls_obj-objtype = lv_obj_type.
|
|
223
|
-
ls_obj-objname = lv_obj_name.
|
|
224
|
-
|
|
225
|
-
DATA lt_objects TYPE scit_objs.
|
|
226
|
-
APPEND ls_obj TO lt_objects.
|
|
227
|
-
|
|
228
|
-
" Create unique name for inspection
|
|
229
|
-
DATA lv_name TYPE sci_objs.
|
|
230
|
-
CONCATENATE 'SYNT_' sy-uname sy-datum sy-uzeit INTO lv_name.
|
|
231
|
-
|
|
232
|
-
" Create object set
|
|
233
|
-
DATA(lo_objset) = cl_ci_objectset=>save_from_list(
|
|
234
|
-
p_name = lv_name
|
|
235
|
-
p_objects = lt_objects ).
|
|
236
|
-
|
|
237
|
-
" Get check variant for syntax check
|
|
238
|
-
DATA(lo_variant) = cl_ci_checkvariant=>get_ref(
|
|
239
|
-
p_user = ''
|
|
240
|
-
p_name = 'SYNTAX_CHECK' ).
|
|
241
|
-
|
|
242
|
-
" Create inspection
|
|
243
|
-
cl_ci_inspection=>create(
|
|
244
|
-
EXPORTING
|
|
245
|
-
p_user = sy-uname
|
|
246
|
-
p_name = lv_name
|
|
247
|
-
RECEIVING
|
|
248
|
-
p_ref = DATA(lo_inspection) ).
|
|
249
|
-
|
|
250
|
-
" Set inspection with object set and variant
|
|
251
|
-
lo_inspection->set(
|
|
252
|
-
EXPORTING
|
|
253
|
-
p_chkv = lo_variant
|
|
254
|
-
p_objs = lo_objset ).
|
|
255
|
-
|
|
256
|
-
" Save inspection
|
|
257
|
-
lo_inspection->save( ).
|
|
258
|
-
|
|
259
|
-
" Run inspection via RFC (for async CLI execution)
|
|
260
|
-
lo_inspection->run(
|
|
261
|
-
EXPORTING
|
|
262
|
-
p_howtorun = 'R'
|
|
263
|
-
EXCEPTIONS
|
|
264
|
-
invalid_check_version = 1
|
|
265
|
-
OTHERS = 2 ).
|
|
266
|
-
|
|
267
|
-
" Get results
|
|
268
|
-
DATA lt_list TYPE scit_alvlist.
|
|
269
|
-
lo_inspection->plain_list( IMPORTING p_list = lt_list ).
|
|
270
|
-
|
|
271
|
-
" Parse results
|
|
272
|
-
LOOP AT lt_list INTO DATA(ls_list).
|
|
273
|
-
" Only include errors for the requested object
|
|
274
|
-
IF ls_list-objtype = lv_obj_type AND ls_list-objname = lv_obj_name.
|
|
275
|
-
CLEAR ls_error.
|
|
276
|
-
ls_error-line = ls_list-line.
|
|
277
|
-
ls_error-column = ls_list-col.
|
|
278
|
-
ls_error-text = ls_list-text.
|
|
279
|
-
ls_error-word = ls_list-code.
|
|
280
|
-
APPEND ls_error TO rs_result-errors.
|
|
281
|
-
ENDIF.
|
|
282
|
-
ENDLOOP.
|
|
283
|
-
|
|
284
|
-
" Cleanup
|
|
285
|
-
lo_inspection->delete(
|
|
286
|
-
EXCEPTIONS
|
|
287
|
-
locked = 1
|
|
288
|
-
error_in_enqueue = 2
|
|
289
|
-
not_authorized = 3
|
|
290
|
-
exceptn_appl_exists = 4
|
|
291
|
-
OTHERS = 5 ).
|
|
292
|
-
|
|
293
|
-
lo_objset->delete(
|
|
294
|
-
EXCEPTIONS
|
|
295
|
-
exists_in_insp = 1
|
|
296
|
-
locked = 2
|
|
297
|
-
error_in_enqueue = 3
|
|
298
|
-
not_authorized = 4
|
|
299
|
-
exists_in_objs = 5
|
|
300
|
-
OTHERS = 6 ).
|
|
301
|
-
|
|
302
|
-
rs_result-error_count = lines( rs_result-errors ).
|
|
303
|
-
IF rs_result-error_count > 0.
|
|
304
|
-
rs_result-success = abap_false.
|
|
305
|
-
ENDIF.
|
|
306
|
-
|
|
307
|
-
CATCH cx_root INTO DATA(lx_error).
|
|
308
|
-
rs_result-success = abap_false.
|
|
309
|
-
rs_result-error_count = 1.
|
|
310
|
-
ls_error-line = '1'.
|
|
311
|
-
ls_error-column = '1'.
|
|
312
|
-
ls_error-text = lx_error->get_text( ).
|
|
313
|
-
ls_error-word = ''.
|
|
314
|
-
APPEND ls_error TO rs_result-errors.
|
|
315
|
-
ENDTRY.
|
|
316
|
-
ENDMETHOD.
|
|
317
|
-
|
|
318
|
-
METHOD zif_abgagt_agent~run_tests.
|
|
319
|
-
" Initialize result
|
|
320
|
-
rs_result-success = abap_false.
|
|
321
|
-
rs_result-test_count = 0.
|
|
322
|
-
rs_result-passed_count = 0.
|
|
323
|
-
rs_result-failed_count = 0.
|
|
324
|
-
|
|
325
|
-
" Get test classes to run
|
|
326
|
-
DATA(lt_test_classes) = get_test_classes(
|
|
327
|
-
iv_package = iv_package
|
|
328
|
-
it_objects = it_objects ).
|
|
329
|
-
|
|
330
|
-
IF lt_test_classes IS INITIAL.
|
|
331
|
-
rs_result-message = 'No test classes found'.
|
|
332
|
-
RETURN.
|
|
333
|
-
ENDIF.
|
|
334
|
-
|
|
335
|
-
rs_result-message = |Found { lines( lt_test_classes ) } test class(es)|.
|
|
336
|
-
|
|
337
|
-
" Run AUnit tests
|
|
338
|
-
rs_result-results = run_aunit_tests( lt_test_classes ).
|
|
339
|
-
|
|
340
|
-
IF rs_result-results IS INITIAL.
|
|
341
|
-
rs_result-message = |No test results - { rs_result-message }|.
|
|
342
|
-
RETURN.
|
|
343
|
-
ENDIF.
|
|
344
|
-
|
|
345
|
-
" Count results
|
|
346
|
-
count_results(
|
|
347
|
-
EXPORTING it_results = rs_result-results
|
|
348
|
-
CHANGING rs_stats = rs_result ).
|
|
349
|
-
|
|
350
|
-
IF rs_result-failed_count = 0.
|
|
351
|
-
rs_result-success = abap_true.
|
|
352
|
-
rs_result-message = |All { rs_result-test_count } tests passed|.
|
|
353
|
-
ELSE.
|
|
354
|
-
rs_result-message = |{ rs_result-failed_count } of { rs_result-test_count } tests failed|.
|
|
355
|
-
ENDIF.
|
|
356
|
-
ENDMETHOD.
|
|
357
|
-
|
|
358
166
|
METHOD configure_credentials.
|
|
359
167
|
zcl_abapgit_persist_factory=>get_user( )->set_repo_git_user_name(
|
|
360
168
|
iv_url = iv_url iv_username = iv_username ).
|
|
@@ -605,163 +413,6 @@ CLASS zcl_abgagt_agent IMPLEMENTATION.
|
|
|
605
413
|
ENDWHILE.
|
|
606
414
|
ENDMETHOD.
|
|
607
415
|
|
|
608
|
-
METHOD get_test_classes.
|
|
609
|
-
DATA: lt_tadir TYPE TABLE OF tadir.
|
|
610
|
-
|
|
611
|
-
FIELD-SYMBOLS: <ls_tadir> LIKE LINE OF lt_tadir.
|
|
612
|
-
|
|
613
|
-
" Get all test classes from package
|
|
614
|
-
IF iv_package IS NOT INITIAL.
|
|
615
|
-
SELECT * FROM tadir
|
|
616
|
-
INTO TABLE lt_tadir
|
|
617
|
-
WHERE devclass = iv_package
|
|
618
|
-
AND object = 'CLAS'
|
|
619
|
-
AND obj_name LIKE '%_TEST'
|
|
620
|
-
ORDER BY obj_name.
|
|
621
|
-
|
|
622
|
-
LOOP AT lt_tadir ASSIGNING <ls_tadir>.
|
|
623
|
-
APPEND INITIAL LINE TO rt_classes ASSIGNING FIELD-SYMBOL(<ls_class>).
|
|
624
|
-
<ls_class>-object_type = 'CLAS'.
|
|
625
|
-
<ls_class>-object_name = <ls_tadir>-obj_name.
|
|
626
|
-
ENDLOOP.
|
|
627
|
-
ENDIF.
|
|
628
|
-
|
|
629
|
-
" Add specified objects
|
|
630
|
-
IF it_objects IS NOT INITIAL.
|
|
631
|
-
LOOP AT it_objects ASSIGNING FIELD-SYMBOL(<ls_obj>).
|
|
632
|
-
APPEND INITIAL LINE TO rt_classes ASSIGNING <ls_class>.
|
|
633
|
-
<ls_class>-object_type = <ls_obj>-object_type.
|
|
634
|
-
<ls_class>-object_name = <ls_obj>-object_name.
|
|
635
|
-
ENDLOOP.
|
|
636
|
-
ENDIF.
|
|
637
|
-
|
|
638
|
-
" Remove duplicates
|
|
639
|
-
SORT rt_classes BY object_name.
|
|
640
|
-
DELETE ADJACENT DUPLICATES FROM rt_classes COMPARING object_name.
|
|
641
|
-
|
|
642
|
-
ENDMETHOD.
|
|
643
|
-
|
|
644
|
-
METHOD run_aunit_tests.
|
|
645
|
-
" Run unit tests using CL_SUT_AUNIT_RUNNER
|
|
646
|
-
DATA: lo_runner TYPE REF TO cl_sut_aunit_runner.
|
|
647
|
-
|
|
648
|
-
" Create runner using s_create
|
|
649
|
-
cl_sut_aunit_runner=>s_create(
|
|
650
|
-
EXPORTING
|
|
651
|
-
p_cov = abap_false
|
|
652
|
-
i_flg_api = abap_true
|
|
653
|
-
RECEIVING
|
|
654
|
-
r_ref_runner = lo_runner ).
|
|
655
|
-
|
|
656
|
-
" Configure runner
|
|
657
|
-
lo_runner->p_disp = abap_false. " Don't show results UI
|
|
658
|
-
lo_runner->p_save = abap_true. " Save values
|
|
659
|
-
lo_runner->p_runmd = 'E'. " Execute only (not plan)
|
|
660
|
-
|
|
661
|
-
" Set test classes
|
|
662
|
-
DATA lv_test_classes TYPE string.
|
|
663
|
-
LOOP AT it_classes ASSIGNING FIELD-SYMBOL(<ls_class>).
|
|
664
|
-
IF lv_test_classes IS INITIAL.
|
|
665
|
-
lv_test_classes = <ls_class>-object_name.
|
|
666
|
-
ELSE.
|
|
667
|
-
lv_test_classes = |{ lv_test_classes } { <ls_class>-object_name }|.
|
|
668
|
-
ENDIF.
|
|
669
|
-
ENDLOOP.
|
|
670
|
-
|
|
671
|
-
" Run tests
|
|
672
|
-
TRY.
|
|
673
|
-
lo_runner->run(
|
|
674
|
-
EXPORTING
|
|
675
|
-
i_flg_select_only = abap_false
|
|
676
|
-
EXCEPTIONS
|
|
677
|
-
OTHERS = 1 ).
|
|
678
|
-
CATCH cx_sut_error.
|
|
679
|
-
RETURN.
|
|
680
|
-
ENDTRY.
|
|
681
|
-
|
|
682
|
-
IF sy-subrc <> 0.
|
|
683
|
-
RETURN.
|
|
684
|
-
ENDIF.
|
|
685
|
-
|
|
686
|
-
" Get results from tab_objects
|
|
687
|
-
DATA(lt_objects) = lo_runner->tab_objects.
|
|
688
|
-
|
|
689
|
-
IF lt_objects IS INITIAL.
|
|
690
|
-
RETURN.
|
|
691
|
-
ENDIF.
|
|
692
|
-
|
|
693
|
-
" Process results - structure: OBJECT-TAB_TESTCLASSES-TAB_METHODS
|
|
694
|
-
LOOP AT lt_objects ASSIGNING FIELD-SYMBOL(<ls_object>).
|
|
695
|
-
DATA(lv_obj_name) = <ls_object>-obj_name.
|
|
696
|
-
|
|
697
|
-
" Loop through test classes
|
|
698
|
-
LOOP AT <ls_object>-tab_testclasses ASSIGNING FIELD-SYMBOL(<ls_tcl>).
|
|
699
|
-
DATA(lv_tcl_name) = <ls_tcl>-testclass.
|
|
700
|
-
|
|
701
|
-
" Loop through test methods
|
|
702
|
-
LOOP AT <ls_tcl>-tab_methods ASSIGNING FIELD-SYMBOL(<ls_method>).
|
|
703
|
-
" Extract fields dynamically since structure names vary
|
|
704
|
-
DATA: lv_methodname TYPE string,
|
|
705
|
-
lv_kind TYPE string,
|
|
706
|
-
lv_desc TYPE string,
|
|
707
|
-
lv_src TYPE string.
|
|
708
|
-
|
|
709
|
-
ASSIGN COMPONENT 'METHODNAME' OF STRUCTURE <ls_method> TO FIELD-SYMBOL(<lv_mname>).
|
|
710
|
-
IF sy-subrc = 0 AND <lv_mname> IS ASSIGNED.
|
|
711
|
-
lv_methodname = <lv_mname>.
|
|
712
|
-
ENDIF.
|
|
713
|
-
|
|
714
|
-
ASSIGN COMPONENT 'KIND' OF STRUCTURE <ls_method> TO FIELD-SYMBOL(<lv_kind>).
|
|
715
|
-
IF sy-subrc = 0 AND <lv_kind> IS ASSIGNED.
|
|
716
|
-
lv_kind = <lv_kind>.
|
|
717
|
-
ENDIF.
|
|
718
|
-
|
|
719
|
-
ASSIGN COMPONENT 'DESCRIPTION' OF STRUCTURE <ls_method> TO FIELD-SYMBOL(<lv_desc>).
|
|
720
|
-
IF sy-subrc = 0 AND <lv_desc> IS ASSIGNED.
|
|
721
|
-
lv_desc = <lv_desc>.
|
|
722
|
-
ENDIF.
|
|
723
|
-
|
|
724
|
-
ASSIGN COMPONENT 'SOURCE' OF STRUCTURE <ls_method> TO FIELD-SYMBOL(<lv_src>).
|
|
725
|
-
IF sy-subrc = 0 AND <lv_src> IS ASSIGNED.
|
|
726
|
-
lv_src = <lv_src>.
|
|
727
|
-
ENDIF.
|
|
728
|
-
|
|
729
|
-
DATA(ls_result) = VALUE zif_abgagt_agent=>ty_test_result(
|
|
730
|
-
object_type = 'CLAS'
|
|
731
|
-
object_name = lv_obj_name
|
|
732
|
-
test_method = lv_methodname
|
|
733
|
-
status = lv_kind
|
|
734
|
-
message = lv_desc
|
|
735
|
-
line = lv_src
|
|
736
|
-
).
|
|
737
|
-
APPEND ls_result TO rt_results.
|
|
738
|
-
ENDLOOP.
|
|
739
|
-
ENDLOOP.
|
|
740
|
-
ENDLOOP.
|
|
741
|
-
ENDMETHOD.
|
|
742
|
-
|
|
743
|
-
METHOD count_results.
|
|
744
|
-
rs_stats-test_count = lines( it_results ).
|
|
745
|
-
rs_stats-passed_count = 0.
|
|
746
|
-
rs_stats-failed_count = 0.
|
|
747
|
-
|
|
748
|
-
LOOP AT it_results ASSIGNING FIELD-SYMBOL(<ls_result>).
|
|
749
|
-
CASE <ls_result>-status.
|
|
750
|
-
WHEN 'P' OR 'S'. " Passed or Success
|
|
751
|
-
rs_stats-passed_count = rs_stats-passed_count + 1.
|
|
752
|
-
WHEN 'A' OR 'E' OR 'F'. " Abort, Error, or Failed
|
|
753
|
-
rs_stats-failed_count = rs_stats-failed_count + 1.
|
|
754
|
-
WHEN OTHERS.
|
|
755
|
-
IF <ls_result>-message CS 'Passed' OR <ls_result>-message CS 'passed'.
|
|
756
|
-
rs_stats-passed_count = rs_stats-passed_count + 1.
|
|
757
|
-
ELSE.
|
|
758
|
-
rs_stats-failed_count = rs_stats-failed_count + 1.
|
|
759
|
-
ENDIF.
|
|
760
|
-
ENDCASE.
|
|
761
|
-
ENDLOOP.
|
|
762
|
-
|
|
763
|
-
ENDMETHOD.
|
|
764
|
-
|
|
765
416
|
METHOD get_version.
|
|
766
417
|
rv_version = '1.0.0'.
|
|
767
418
|
ENDMETHOD.
|
|
@@ -22,9 +22,11 @@ CLASS zcl_abgagt_cmd_factory IMPLEMENTATION.
|
|
|
22
22
|
METHOD constructor.
|
|
23
23
|
" Build command to class name mapping
|
|
24
24
|
mt_command_map = VALUE #(
|
|
25
|
-
( command = zif_abgagt_command=>gc_pull
|
|
25
|
+
( command = zif_abgagt_command=>gc_pull class_name = 'ZCL_ABGAGT_COMMAND_PULL' )
|
|
26
26
|
( command = zif_abgagt_command=>gc_inspect class_name = 'ZCL_ABGAGT_COMMAND_INSPECT' )
|
|
27
27
|
( command = zif_abgagt_command=>gc_unit class_name = 'ZCL_ABGAGT_COMMAND_UNIT' )
|
|
28
|
+
( command = zif_abgagt_command=>gc_create class_name = 'ZCL_ABGAGT_COMMAND_CREATE' )
|
|
29
|
+
( command = zif_abgagt_command=>gc_import class_name = 'ZCL_ABGAGT_COMMAND_IMPORT' )
|
|
28
30
|
).
|
|
29
31
|
ENDMETHOD.
|
|
30
32
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_command_create DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
5
|
+
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_command.
|
|
8
|
+
|
|
9
|
+
TYPES: BEGIN OF ty_create_params,
|
|
10
|
+
url TYPE string,
|
|
11
|
+
branch TYPE string,
|
|
12
|
+
package TYPE string,
|
|
13
|
+
display_name TYPE string,
|
|
14
|
+
name TYPE string,
|
|
15
|
+
folder_logic TYPE string,
|
|
16
|
+
username TYPE string,
|
|
17
|
+
password TYPE string,
|
|
18
|
+
END OF ty_create_params.
|
|
19
|
+
|
|
20
|
+
ENDCLASS.
|
|
21
|
+
|
|
22
|
+
CLASS zcl_abgagt_command_create IMPLEMENTATION.
|
|
23
|
+
|
|
24
|
+
METHOD zif_abgagt_command~get_name.
|
|
25
|
+
rv_name = 'CREATE'.
|
|
26
|
+
ENDMETHOD.
|
|
27
|
+
|
|
28
|
+
METHOD zif_abgagt_command~execute.
|
|
29
|
+
DATA: ls_params TYPE ty_create_params,
|
|
30
|
+
lv_package TYPE devclass,
|
|
31
|
+
li_repo TYPE REF TO zif_abapgit_repo.
|
|
32
|
+
|
|
33
|
+
IF is_param IS SUPPLIED.
|
|
34
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
35
|
+
ENDIF.
|
|
36
|
+
|
|
37
|
+
IF ls_params-folder_logic IS INITIAL.
|
|
38
|
+
ls_params-folder_logic = 'PREFIX'.
|
|
39
|
+
ENDIF.
|
|
40
|
+
|
|
41
|
+
IF ls_params-url IS INITIAL.
|
|
42
|
+
rv_result = '{"success":"","error":"URL is required"}'.
|
|
43
|
+
RETURN.
|
|
44
|
+
ENDIF.
|
|
45
|
+
|
|
46
|
+
IF ls_params-package IS INITIAL.
|
|
47
|
+
rv_result = '{"success":"","error":"Package is required"}'.
|
|
48
|
+
RETURN.
|
|
49
|
+
ENDIF.
|
|
50
|
+
|
|
51
|
+
lv_package = ls_params-package.
|
|
52
|
+
|
|
53
|
+
IF ls_params-username IS NOT INITIAL AND ls_params-password IS NOT INITIAL.
|
|
54
|
+
zcl_abapgit_persist_factory=>get_user( )->set_repo_git_user_name(
|
|
55
|
+
iv_url = ls_params-url iv_username = ls_params-username ).
|
|
56
|
+
zcl_abapgit_persist_factory=>get_user( )->set_repo_login(
|
|
57
|
+
iv_url = ls_params-url iv_login = ls_params-username ).
|
|
58
|
+
zcl_abapgit_login_manager=>set_basic(
|
|
59
|
+
iv_uri = ls_params-url
|
|
60
|
+
iv_username = ls_params-username
|
|
61
|
+
iv_password = ls_params-password ).
|
|
62
|
+
ENDIF.
|
|
63
|
+
|
|
64
|
+
TRY.
|
|
65
|
+
li_repo = zcl_abapgit_repo_srv=>get_instance( )->new_online(
|
|
66
|
+
iv_url = ls_params-url
|
|
67
|
+
iv_branch_name = ls_params-branch
|
|
68
|
+
iv_display_name = ls_params-display_name
|
|
69
|
+
iv_name = ls_params-name
|
|
70
|
+
iv_package = lv_package
|
|
71
|
+
iv_folder_logic = ls_params-folder_logic ).
|
|
72
|
+
CATCH zcx_abapgit_exception INTO DATA(lx_error).
|
|
73
|
+
rv_result = '{"success":"","error":"' && lx_error->get_text( ) && '"}'.
|
|
74
|
+
RETURN.
|
|
75
|
+
ENDTRY.
|
|
76
|
+
|
|
77
|
+
DATA lv_response TYPE string.
|
|
78
|
+
lv_response = '{"success":"X",'.
|
|
79
|
+
lv_response = lv_response && '"repo_key":"' && li_repo->get_key( ) && '",'.
|
|
80
|
+
lv_response = lv_response && '"repo_name":"' && li_repo->get_name( ) && '",'.
|
|
81
|
+
lv_response = lv_response && '"message":"Repository created successfully"}'.
|
|
82
|
+
|
|
83
|
+
rv_result = lv_response.
|
|
84
|
+
ENDMETHOD.
|
|
85
|
+
|
|
86
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_CREATE</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>ABAP Git Agent - Create Command</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
*"*"use source
|
|
2
|
+
*"*"Local Interface:
|
|
3
|
+
*"**********************************************************************
|
|
4
|
+
CLASS zcl_abgagt_command_import DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
|
5
|
+
|
|
6
|
+
PUBLIC SECTION.
|
|
7
|
+
INTERFACES zif_abgagt_command.
|
|
8
|
+
|
|
9
|
+
TYPES: BEGIN OF ty_import_params,
|
|
10
|
+
url TYPE string,
|
|
11
|
+
message TYPE string,
|
|
12
|
+
username TYPE string,
|
|
13
|
+
password TYPE string,
|
|
14
|
+
END OF ty_import_params.
|
|
15
|
+
|
|
16
|
+
ENDCLASS.
|
|
17
|
+
|
|
18
|
+
CLASS zcl_abgagt_command_import IMPLEMENTATION.
|
|
19
|
+
|
|
20
|
+
METHOD zif_abgagt_command~get_name.
|
|
21
|
+
rv_name = 'IMPORT'.
|
|
22
|
+
ENDMETHOD.
|
|
23
|
+
|
|
24
|
+
METHOD zif_abgagt_command~execute.
|
|
25
|
+
DATA: ls_params TYPE ty_import_params,
|
|
26
|
+
li_repo TYPE REF TO zif_abapgit_repo,
|
|
27
|
+
li_repo_online TYPE REF TO zif_abapgit_repo_online,
|
|
28
|
+
lo_stage TYPE REF TO zcl_abapgit_stage,
|
|
29
|
+
lt_files TYPE zif_abapgit_definitions=>ty_files_item_tt,
|
|
30
|
+
lv_package TYPE devclass,
|
|
31
|
+
lv_message TYPE string,
|
|
32
|
+
lv_files_staged TYPE i.
|
|
33
|
+
|
|
34
|
+
" Use separate variables to avoid inline DATA issues
|
|
35
|
+
DATA: li_user TYPE REF TO zif_abapgit_persist_user,
|
|
36
|
+
lv_committer_name TYPE string,
|
|
37
|
+
lv_committer_email TYPE string.
|
|
38
|
+
|
|
39
|
+
TRY.
|
|
40
|
+
IF is_param IS SUPPLIED.
|
|
41
|
+
ls_params = CORRESPONDING #( is_param ).
|
|
42
|
+
ENDIF.
|
|
43
|
+
|
|
44
|
+
" Validate URL
|
|
45
|
+
IF ls_params-url IS INITIAL.
|
|
46
|
+
rv_result = '{"success":"","error":"URL is required"}'.
|
|
47
|
+
RETURN.
|
|
48
|
+
ENDIF.
|
|
49
|
+
|
|
50
|
+
" Configure credentials if provided
|
|
51
|
+
IF ls_params-username IS NOT INITIAL AND ls_params-password IS NOT INITIAL.
|
|
52
|
+
zcl_abapgit_persist_factory=>get_user( )->set_repo_git_user_name(
|
|
53
|
+
iv_url = ls_params-url iv_username = ls_params-username ).
|
|
54
|
+
zcl_abapgit_persist_factory=>get_user( )->set_repo_login(
|
|
55
|
+
iv_url = ls_params-url iv_login = ls_params-username ).
|
|
56
|
+
zcl_abapgit_login_manager=>set_basic(
|
|
57
|
+
iv_uri = ls_params-url
|
|
58
|
+
iv_username = ls_params-username
|
|
59
|
+
iv_password = ls_params-password ).
|
|
60
|
+
ENDIF.
|
|
61
|
+
|
|
62
|
+
" Find repository by URL
|
|
63
|
+
zcl_abapgit_repo_srv=>get_instance( )->get_repo_from_url(
|
|
64
|
+
EXPORTING iv_url = ls_params-url
|
|
65
|
+
IMPORTING ei_repo = li_repo ).
|
|
66
|
+
|
|
67
|
+
IF li_repo IS NOT BOUND.
|
|
68
|
+
rv_result = '{"success":"","error":"Repository not found"}'.
|
|
69
|
+
RETURN.
|
|
70
|
+
ENDIF.
|
|
71
|
+
|
|
72
|
+
" Cast to online repo for push operations
|
|
73
|
+
li_repo_online ?= li_repo.
|
|
74
|
+
|
|
75
|
+
" Get package from repository
|
|
76
|
+
lv_package = li_repo->get_package( ).
|
|
77
|
+
|
|
78
|
+
" Build commit message if not provided
|
|
79
|
+
IF ls_params-message IS INITIAL.
|
|
80
|
+
lv_message = |feat: initial import from ABAP package { lv_package }|.
|
|
81
|
+
ELSE.
|
|
82
|
+
lv_message = ls_params-message.
|
|
83
|
+
ENDIF.
|
|
84
|
+
|
|
85
|
+
" Refresh repository
|
|
86
|
+
li_repo->refresh( ).
|
|
87
|
+
|
|
88
|
+
" Get local files
|
|
89
|
+
lt_files = li_repo->get_files_local( ).
|
|
90
|
+
|
|
91
|
+
" Count files
|
|
92
|
+
lv_files_staged = lines( lt_files ).
|
|
93
|
+
|
|
94
|
+
" Check if there are files to import
|
|
95
|
+
IF lv_files_staged = 0.
|
|
96
|
+
rv_result = '{"success":"","error":"No objects found in package"}'.
|
|
97
|
+
RETURN.
|
|
98
|
+
ENDIF.
|
|
99
|
+
|
|
100
|
+
" Create stage
|
|
101
|
+
CREATE OBJECT lo_stage.
|
|
102
|
+
|
|
103
|
+
" Add all files to stage
|
|
104
|
+
LOOP AT lt_files ASSIGNING FIELD-SYMBOL(<ls_file>).
|
|
105
|
+
lo_stage->add(
|
|
106
|
+
iv_path = <ls_file>-file-path
|
|
107
|
+
iv_filename = <ls_file>-file-filename
|
|
108
|
+
iv_data = <ls_file>-file-data ).
|
|
109
|
+
ENDLOOP.
|
|
110
|
+
|
|
111
|
+
" Get user details for committer
|
|
112
|
+
li_user = zcl_abapgit_persist_factory=>get_user( ).
|
|
113
|
+
lv_committer_name = li_user->get_default_git_user_name( ).
|
|
114
|
+
lv_committer_email = li_user->get_default_git_user_email( ).
|
|
115
|
+
|
|
116
|
+
" Prepare commit
|
|
117
|
+
DATA: ls_comment TYPE zif_abapgit_git_definitions=>ty_comment.
|
|
118
|
+
ls_comment-committer-name = lv_committer_name.
|
|
119
|
+
ls_comment-committer-email = lv_committer_email.
|
|
120
|
+
ls_comment-comment = lv_message.
|
|
121
|
+
|
|
122
|
+
" Commit and push
|
|
123
|
+
li_repo_online->push(
|
|
124
|
+
is_comment = ls_comment
|
|
125
|
+
io_stage = lo_stage ).
|
|
126
|
+
|
|
127
|
+
COMMIT WORK.
|
|
128
|
+
|
|
129
|
+
rv_result = '{"success":"X","files_staged":"' && lv_files_staged && '","commit_message":"' && lv_message && '"}'.
|
|
130
|
+
|
|
131
|
+
CATCH zcx_abapgit_exception INTO DATA(lx_error).
|
|
132
|
+
rv_result = '{"success":"","error":"' && lx_error->get_text( ) && '"}'.
|
|
133
|
+
CATCH cx_root INTO DATA(lx_other).
|
|
134
|
+
rv_result = '{"success":"","error":"' && lx_other->get_text( ) && '"}'.
|
|
135
|
+
ENDTRY.
|
|
136
|
+
ENDMETHOD.
|
|
137
|
+
|
|
138
|
+
ENDCLASS.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
|
3
|
+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
|
4
|
+
<asx:values>
|
|
5
|
+
<VSEOCLASS>
|
|
6
|
+
<CLSNAME>ZCL_ABGAGT_COMMAND_IMPORT</CLSNAME>
|
|
7
|
+
<LANGU>E</LANGU>
|
|
8
|
+
<DESCRIPT>Import command for ABAP Git Agent</DESCRIPT>
|
|
9
|
+
<EXPOSURE>2</EXPOSURE>
|
|
10
|
+
<STATE>1</STATE>
|
|
11
|
+
<UNICODE>X</UNICODE>
|
|
12
|
+
</VSEOCLASS>
|
|
13
|
+
</asx:values>
|
|
14
|
+
</asx:abap>
|
|
15
|
+
</abapGit>
|