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

Way to get whether the grgit initialization was successful from the service #362

Closed
Vampire opened this issue Feb 17, 2022 · 2 comments
Closed

Comments

@Vampire
Copy link
Contributor

Vampire commented Feb 17, 2022

It would be nice if the GrgitService would have a way to determine whether grgit could be initialized or not instead of having a hard failure on get()-ing the service from the provider.
This makes using the grgit-service plugin a bit cumbersome.
You would currenltly use some construct like

val grgit by lazy(NONE) {
    runCatching {
        grgitService.service.get().grgit
    }.getOrNull()
}

It would be nicer if the service initialization would not fail and instead the service provides the information whether grgit is available, for example by returning a null value like with the grgit plugin.

@Vampire Vampire changed the title Way to get Way to get whther the grgit initialization was successful from the service Feb 17, 2022
@Vampire Vampire changed the title Way to get whther the grgit initialization was successful from the service Way to get whether the grgit initialization was successful from the service Feb 17, 2022
@ajoberstar
Copy link
Owner

I made a point of keeping the org.ajoberstar.grgit behavior the same as in v4 (falling back to null) for backwards compatibility, but wanted to play out how big of a deal it would be for the service to hard fail. So the starting point was keep it simple for the new plugin and learn from user feedback.

I was thinking that in some cases, the action you're trying to do can't legitimately be performed if there is no repo. For example, if I have a task to push to a repository, I likely wouldn't want to run it if I had a copy of the project outside of a Git repo. Not sure if it should silently work in that case either, but maybe the user wants an easier way to make that decision for themselves.

Perhaps it should just return an Optional<Grgit> and make it more explicit to the user they need to handle that no-repo case.

@Vampire
Copy link
Contributor Author

Vampire commented Jun 29, 2023

Any news on this one?
Just hit it again, that it is cumbersome if the Git repository might be missing or the build might run in a Git worktree.

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

No branches or pull requests

2 participants