cancel
Showing results for 
Search instead for 
Did you mean: 

WebIDE Extension - Integration with external git

skek
Explorer
0 Kudos

Hello,

I would like to create a Git plugin for the WebIDE. The plugin (extension) should connect a project with an external git.

In our case, we use gitlab. The Gitlab API is accessed via HTTP requests and creates an empty git repository. We have already been able to implement this as a plugin.

But afterwards we must initialize the local git repository of an existing project. Then, the remote origin of this local git repository should be set to the created gitlab repository.

For this plugin (extension) I would like to use the two existing functions/features of the WebIDE.

1. Initialization of the local git repository(see picture 1):

2. Set the project remote (see picture 2):

This will open a dialog in which you have to enter the URL of the Git repository (see picture 3).

I would like to execute the two steps automatically in the background within my plugin without opening the dialogs.

As far as I know these two controls are use:

1. Sap.watt.ideplatform.gitclient/command/InitRepository

2. Sap.watt.ideplatform.gitclient/command/SetRemote

Does anybody know, if there is a way to call the two methods InitRepository and SetRemote without the dialogs?

If so, could you kindly send me a code example?

If this doesn't work, I'd like to call the methods that open the dialogs. Is this possible?

Or is it possible to execute the git commands

- git add -A

- git remote add origin <URL of Repository>

via Javascript

Best regards

Kevin Kussyk

Accepted Solutions (1)

Accepted Solutions (1)

rima-sirich
Advisor
Advisor
0 Kudos

Hi Kevin,

I am afraid that git APIs are not public API and you are not supposed to use them. But since sap.watt.ideplatform.gitclient/command/InitRepository and sap.watt.ideplatform.gitclient/command/SetRemote are commands you can use the following workaround:

execute: function () {
   var that = this;
   return this.context.service.command.getCommand("gitclient.initrepository").then(function (oInitRepoCommand) {
	return oInitRepoCommand.getService().execute().then(function () {
		return that.context.service.command.getCommand("gitclient.setRemote").then(function (oSetRemoteCommand) {
			return oSetRemoteCommand.getService().execute().then(function () {
				// do something
			});
		});
	});
   });
}

Regards,

Rima

skek
Explorer
0 Kudos

Thanks for the code snippet !

It helped me a lot. Now the plugin works.

Best Regards,

Kevin

Answers (0)