Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Exit in zcl_abapgit_oo_serializer methods #5050

Closed
AlexandreHT opened this issue Oct 21, 2021 · 4 comments · Fixed by #5194
Closed

Add User-Exit in zcl_abapgit_oo_serializer methods #5050

AlexandreHT opened this issue Oct 21, 2021 · 4 comments · Fixed by #5194
Labels
new feature New feature or request

Comments

@AlexandreHT
Copy link
Contributor

Method serialize_abap_clif_source in zcl_abapgit_oo_serializer contains a user exit (custom_serialize_abap_clif) that enables me to perform a custom Pretty print different from the one I use on my system (cf. https://gist.github.com/mbtools/71aa345a8ccb8f375568f9f337569154).

Such a User Exit is missing in the following methods:

  • serialize_locals_def
  • serialize_locals_imp
  • serialize_macros
  • serialize_testclasses

Thanks,

@mbtools
Copy link
Member

mbtools commented Oct 21, 2021

it should be a "code post-processing" exit and also available for object types like prog, fugr, type, and others that have embedded code.

@larshp
Copy link
Member

larshp commented Nov 7, 2021

user exit referenced = https://docs.abapgit.org/ref-exits.html#custom_serialize_abap_clif

Suggest a new exit SERIALIZE_POSTPROCESS, which can be used to change everything

@larshp larshp added the new feature New feature or request label Nov 7, 2021
@AlexandreHT
Copy link
Contributor Author

Ideally, user exit execution could be restricted to push. (My use case : Code pushed to public git repo should be formatted but code pulled from other repo (eg. abap2xlsx) should be copied as is, in order to avoid false flag diff after import).

@mbtools
Copy link
Member

mbtools commented Dec 3, 2021

If we only do it on push, it will be hidden to the user as to what happens. I agree with Lars that it should happen at the end of serialize process. Then the results will be visible in repo and diff views.

So I think the exit should go at the end of this method:

https://github.com/abapGit/abapGit/blob/main/src/objects/core/zcl_abapgit_serialize.clas.abap#L331-L357

METHOD files_local.
...
*   Call postprocessing
    li_exit = zcl_abapgit_exit=>get_instance( ).

    li_exit->serialize_postprocess( 
      EXPORTING
        iv_package = iv_package
        ii_log     = ii_log 
      CHANGING
        ct_files   = rt_files ).

ENDMETHOD.

For your (our) purpose, you can then loop over all .abap files in ct_files and pass them through pretty-print with the settings you like.

mbtools added a commit that referenced this issue Dec 9, 2021
There are scenarios where you want to serialize objects differently than abapGit. This exit is called at the end of the serialize process and gives an opportunity to change the content of the serialzed files.

One such scenario would be to automatically pretty-print code. This can be achieved by looping over all `.abap` files and processing them accordingly in this exit.

Closes #5050
larshp added a commit that referenced this issue Dec 11, 2021
There are scenarios where you want to serialize objects differently than abapGit. This exit is called at the end of the serialize process and gives an opportunity to change the content of the serialzed files.

One such scenario would be to automatically pretty-print code. This can be achieved by looping over all `.abap` files and processing them accordingly in this exit.

Closes #5050

Co-authored-by: Lars Hvam <larshp@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Development

Successfully merging a pull request may close this issue.

3 participants