Skip to content

Commit

Permalink
added gitlab base url
Browse files Browse the repository at this point in the history
  • Loading branch information
pweingardt committed Aug 13, 2017
1 parent 2056c0a commit bc40370
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Gitlab Connector Core
Bundle-SymbolicName: de.weingardt.mylyn.gitlab.core;singleton:=true
Bundle-Version: 1.5.0
Bundle-Version: 1.6.0
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.mylyn.commons.core;bundle-version="[3.8.0,4.0.0)",
org.eclipse.mylyn.commons.net;bundle-version="[3.8.0,4.0.0)",
Expand Down
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>de.weingardt.mylyn.gitlab</groupId>
<artifactId>de.weingardt.mylyn.gitlab-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<artifactId>de.weingardt.mylyn.gitlab.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,29 @@ private static String constructURL(TaskRepository repository) {
*/
static GitlabConnection validate(TaskRepository repository) throws GitlabException {
try {
Matcher matcher = URLPattern.matcher(repository.getUrl());
if(!matcher.find()) {
throw new GitlabException("Invalid Project-URL!");
String projectPath = null;
String host = null;

if(repository.getProperty("gitlabBaseUrl").trim().length() > 0) {
host = repository.getProperty("gitlabBaseUrl").trim();
if(!repository.getUrl().startsWith(host)) {
throw new GitlabException("Invalid project URL!");
}

projectPath = repository.getUrl().replaceFirst(Matcher.quoteReplacement(host), "");
if(projectPath.startsWith("/")) {
projectPath = projectPath.substring(1);
}
} else {
Matcher matcher = URLPattern.matcher(repository.getUrl());
if(!matcher.find()) {
throw new GitlabException("Invalid Project-URL!");
}

projectPath = matcher.group(2);
host = matcher.group(1);
}

String projectPath = matcher.group(2);
String host = matcher.group(1);
String username = repository.getCredentials(AuthenticationType.REPOSITORY).getUserName();
String password= repository.getCredentials(AuthenticationType.REPOSITORY).getPassword();

Expand Down
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Gitlab Connector UI
Bundle-SymbolicName: de.weingardt.mylyn.gitlab.ui;singleton:=true
Bundle-Version: 1.5.0
Bundle-Version: 1.6.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
Expand Down
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>de.weingardt.mylyn.gitlab</groupId>
<artifactId>de.weingardt.mylyn.gitlab-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<artifactId>de.weingardt.mylyn.gitlab.ui</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import de.weingardt.mylyn.gitlab.core.GitlabConnector;
import de.weingardt.mylyn.gitlab.core.GitlabPluginCore;

public class GitlabRepositorySettingsPage extends AbstractRepositorySettingsPage {

private Button useToken;


private Text gitlabBaseUrl;

public GitlabRepositorySettingsPage(String title, String description,
TaskRepository taskRepository) {
super(title, description, taskRepository);

setNeedsValidateOnFinish(true);
}

Expand All @@ -47,29 +51,44 @@ protected void createAdditionalControls(final Composite composite) {
GridDataFactory.fillDefaults().span(2, 1).applyTo(useToken);

useToken.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
setUsernameFieldEnabled(!useToken.getSelection());
getWizard().getContainer().updateButtons();
}

@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});


Label l = new Label(composite, SWT.NONE);
l.setText("Gitlab base URL");

gitlabBaseUrl = new Text(composite, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().span(1, 1).applyTo(gitlabBaseUrl);

/**
* Set widget texts and check boxes if necessary.
*/
if (serverUrlCombo.getText().length() == 0) {
// This means, that there the user is *not* editing an existing repository configuration
serverUrlCombo.setText("https://your-host.org/namespace/project.git");
} else {
if(getRepository().getProperty("usePrivateToken").equals("true")) {
}

if(getRepository() != null) {
if("true".equals(getRepository().getProperty("usePrivateToken"))) {
useToken.setSelection(true);
setUsernameFieldEnabled(false);
}

if(getRepository().getProperty("gitlabBaseUrl") != null) {
gitlabBaseUrl.setText(getRepository().getProperty("gitlabBaseUrl"));
}
}
}

private void setUsernameFieldEnabled(boolean enabled) {
if(enabled) {
repositoryUserNameEditor.getTextControl(compositeContainer).setEnabled(true);
Expand All @@ -80,7 +99,7 @@ private void setUsernameFieldEnabled(boolean enabled) {
repositoryUserNameEditor.setStringValue("");
repositoryUserNameEditor.getTextControl(compositeContainer).setEnabled(false);
repositoryUserNameEditor.setEmptyStringAllowed(true);
repositoryPasswordEditor.setLabelText("Private token:");
repositoryPasswordEditor.setLabelText("Private token:");
compositeContainer.layout();
}
}
Expand All @@ -95,7 +114,7 @@ public TaskRepository createTaskRepository() {
TaskRepository repo = super.createTaskRepository();
return repo;
}

@Override
public void applyTo(TaskRepository repository) {
repository.setCategory(TaskRepository.CATEGORY_BUGS);
Expand All @@ -105,8 +124,11 @@ public void applyTo(TaskRepository repository) {
} else {
repository.setProperty("usePrivateToken", "false");
}

repository.setProperty("gitlabBaseUrl", gitlabBaseUrl.getText());

}

@Override
protected boolean isMissingCredentials() {
if(useToken != null && useToken.getSelection()) {
Expand All @@ -115,7 +137,7 @@ protected boolean isMissingCredentials() {
return super.isMissingCredentials();
}
}

@Override
protected Validator getValidator(final TaskRepository repository) {
return new Validator() {
Expand All @@ -124,7 +146,7 @@ protected Validator getValidator(final TaskRepository repository) {
public void run(IProgressMonitor monitor) throws CoreException {
GitlabConnector.validate(repository);
}

};
}

Expand Down
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.updatesite/category.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature id="de.weingardt.mylyn.gitlab" version="1.5.0">
<feature id="de.weingardt.mylyn.gitlab" version="1.6.0">
<category name="org.eclipse.mylyn"/>
</feature>
<category-def name="org.eclipse.mylyn" label="Mylyn Connectors">
Expand Down
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab.updatesite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>de.weingardt.mylyn.gitlab</groupId>
<artifactId>de.weingardt.mylyn.gitlab-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<artifactId>de.weingardt.mylyn.gitlab.updatesite</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions de.weingardt.mylyn.gitlab/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="de.weingardt.mylyn.gitlab"
label="Mylyn Gitlab Connector"
version="1.5.0"
version="1.6.0"
provider-name="Weingardt Software">

<description>
Expand All @@ -21,14 +21,14 @@
id="de.weingardt.mylyn.gitlab.core"
download-size="0"
install-size="0"
version="1.5.0"
version="1.6.0"
unpack="false"/>

<plugin
id="de.weingardt.mylyn.gitlab.ui"
download-size="0"
install-size="0"
version="1.5.0"
version="1.6.0"
unpack="false"/>

</feature>
2 changes: 1 addition & 1 deletion de.weingardt.mylyn.gitlab/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<relativePath>../pom.xml</relativePath>
<groupId>de.weingardt.mylyn.gitlab</groupId>
<artifactId>de.weingardt.mylyn.gitlab-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
</parent>

<artifactId>de.weingardt.mylyn.gitlab</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.weingardt.mylyn.gitlab</groupId>
<artifactId>de.weingardt.mylyn.gitlab-parent</artifactId>
<version>1.5.0</version>
<version>1.6.0</version>
<packaging>pom</packaging>

<properties>
Expand Down

0 comments on commit bc40370

Please sign in to comment.