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

Danger Plugin Api surface #198

Open
afaucogney opened this issue Nov 5, 2021 · 5 comments
Open

Danger Plugin Api surface #198

afaucogney opened this issue Nov 5, 2021 · 5 comments

Comments

@afaucogney
Copy link

I'm try to build my first plugin, and I wonder why the DangerPlugin doesn't provide access to git Api ?

I mean I know I can use the git api at the Danger file level, but in my case I have many things to do with it, I would like to encapsulate into a plugin ?

Is there a way to handle my need ? Or maybe this is not yet done ? Or not intended ?

Thanks again for your time

@gianluz
Copy link
Member

gianluz commented Nov 15, 2021

Hi @afaucogney the github api is not available by default inside the danger plugin development on purpose. The reason for that is because we want to avoid situations where some plugins are compatible only with specific versions of danger kotlin. we want to decouple that so your plugin will be compatible with all danger versions.

You can workaround by creating objects and classes that your plugin need and pass that in input in your plugin method, for example:

MyPlugin.doMyCheck(MyGitHubObject(field1, field2, field3)

where MyGitHubObject is your plugin data class that contains all the field you need to perform your checks

@afaucogney
Copy link
Author

Hi @gianluz, I understand your point, and I think that could be relevant for SCM provider as Github, or Gitlab that may update their apis. However, I was talking about the git api, the "Raw".

There are many Danger ruby api that probably use the git api in their implementation.

  • danger-android_permissions_checker
  • lint (filtering)
  • detekt (filtering)

Did we miss-understood each others ?

@gianluz
Copy link
Member

gianluz commented Dec 7, 2021

hi @afaucogney danger ruby follows a completely different architecture, danger kotlin keeps the api as simplest as possible.
Let's suppose something is going to change in the danger git api, because that is binded to a specific version this will invalidate your plugin in newer danger kotlin versions.

If we keep decoupled that, and we just give the basic api, then your plugin will more likely be compatible in other newer danger kotlin versions.

This is a limit we know very well but keeps compatibility.

I'm studying a way to see if we can include some sort of API in the plugin development SDK and how works, or release a separate git danger dependency to include if you need that feature, let's see how the thing evolve.

At the moment, considering danger kotlin runs the Dangerfile that is a script, you could as a workaround run a System command with the git command you would like to run, and convert the output to kotlin objects that is likely what a new library or the plugin sdk will do.

@afaucogney
Copy link
Author

I will try to find a workaround, but the complexity of the plugin I am willing to do is mainly around git diff ... So if the script that setup the plugin get 5x more loc of the plugin itself, I m not sure it will make sense !

Let's see what I can do !

If the danger API git or message change, I'm fine with the fact that the plugin should be updated. I do not see why the message is more important that the git one !

I'm sure we can define a limited git interface that will remain almost stable in the future.

For now I mainly need git-ls and git-diff results !

I will let you know my progress...

@gianluz
Copy link
Member

gianluz commented Dec 7, 2021

i see your point and that's fair to be honest, ok lets see if we can get an sdk with some basic git apis. I will try something to simplify your work. could you please give me a snippet or an example about what you would expect to be like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants