Creating a git repository on New Project generation from a plugin

Answered

I have built an IntelliJ plugin that generates a gradle project using file templates and imports it using an implementation of the JavaModuleBuilder.

As part of this process I would also like to initialise a git repository, set it's upstream and create a new branch for the user. Is there a simple way to do this?

I have added the git4idea plugin to the dependencies and in plugin.xml but regardless of what methods I call on it I can't see it having an affect on the project generated. Currently I am trying to use the methods in GitImpl, such as:

GitImpl().init(project, root)

This appears to have no affect but does give the warning: Activities registered via registerPostStartupActivity must be dumb-aware: com.intellij.ide.impl.NewProjectUril$Lambda...

Is there a more simple way to do this I am missing? I would really appreciate your help

3 comments
Comment actions Permalink

Please post full stacktraces alway.

And please never use *Impl classes directly, git4idea.commands.Git.getInstance().init(...) should do the same

0
Comment actions Permalink

Hi Yann Cebron thank you for replying, apologies for not including a stack trace, the code I had written didn't throw any errors directly (the error I reported above is caused by something else) it just had no affect on the project generated.

All I want to do is run these basic Git commands when generating the project:

git init
git remote add origin "<url>"
git checkout --orphan "<branch name>"

Is that possible by calling the commands provided by git4idea? Any documentation or examples would be incredibly helpful, I really appreciate your help!

0

Please sign in to leave a comment.