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

Bring back Git URL external access of the current project #1536

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public interface View extends SettingsPresenter.View.Section<GeneralSettingsPres

String getDescription();

String getURL();

String getGroupId();

String getArtifactId();
Expand Down Expand Up @@ -125,7 +123,7 @@ public Promise<Void> setup(final ProjectScreenModel model) {
view.setGroupId(pom.getGav().getGroupId());
view.setArtifactId(pom.getGav().getArtifactId());
view.setVersion(pom.getGav().getVersion());
view.setURL(pom.getUrl() != null ? pom.getUrl() : "");
view.setURL(model.getGitUrl());

return promises.create((resolve, reject) -> {
gavPreferences.load(projectScopedResolutionStrategySupplier.get(),
Expand Down Expand Up @@ -208,11 +206,6 @@ void setGroupId(final String groupId) {
fireChangeEvent();
}

void setUrl(final String url) {
pom.setUrl(url);
fireChangeEvent();
}

void setDescription(final String description) {
pom.setDescription(description);
fireChangeEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h3 data-i18n-key="GeneralSettings" data-field="title"></h3>
</div>
<div class="form-group">
<label for="url" data-i18n-key="URL"></label>
<input type="text" class="form-control" id="url">
<input type="text" class="form-control" id="url" readonly>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By making this field read-only this PR is changing the semantics of the URL field in general settings.
Before this PR this field was connected to project pom.xml <url> element.
In this PR this has changed to dynamically display URL of the workbench-managed repository.

This means that we should remove this outdated functionality from GeneralSettings presenter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the semantic of the URL was always intented to be the one present in this PR, use the pom data wasn't the original intentention.

ps: I was part of the UI design and personally asked UX to add this field to cover exactly the Git URL. This was overlooked during the merge.

</div>
<div class="checkbox">
<label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ public void onDescriptionChanged(final ChangeEvent ignore) {
presenter.setDescription(description.value);
}

@EventHandler("url")
public void onUrlChanged(final ChangeEvent ignore) {
presenter.setUrl(url.value);
}

@EventHandler("group-id")
public void onGroupIdChanged(final ChangeEvent ignore) {
presenter.setGroupId(groupId.value);
Expand All @@ -152,11 +147,6 @@ public String getDescription() {
return description.value;
}

@Override
public String getURL() {
return url.value;
}

@Override
public String getGroupId() {
return groupId.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ProjectScreenModel {

private POM pom;
private KModuleModel KModule;
private String gitUrl;
private ProjectImports projectImports;
private ModuleRepositories repositories;
private WhiteList whiteList;
Expand Down Expand Up @@ -59,6 +60,14 @@ public void setKModule(final KModuleModel KModule) {
this.KModule = KModule;
}

public String getGitUrl() {
return gitUrl;
}

public void setGitUrl(String gitUrl) {
this.gitUrl = gitUrl;
}

public ProjectImports getProjectImports() {
return projectImports;
}
Expand Down Expand Up @@ -186,6 +195,9 @@ public boolean equals(Object o) {
if (KModule != null ? !KModule.equals(that.KModule) : that.KModule != null) {
return false;
}
if (gitUrl != null ? !gitUrl.equals(that.gitUrl) : that.gitUrl != null) {
return false;
}
if (pathToKModule != null ? !pathToKModule.equals(that.pathToKModule) : that.pathToKModule != null) {
return false;
}
Expand Down Expand Up @@ -232,6 +244,8 @@ public int hashCode() {
result = ~~result;
result = 31 * result + (KModule != null ? KModule.hashCode() : 0);
result = ~~result;
result = 31 * result + (gitUrl != null ? gitUrl.hashCode() : 0);
result = ~~result;
result = 31 * result + (pathToKModule != null ? pathToKModule.hashCode() : 0);
result = ~~result;
result = 31 * result + (KModuleMetaData != null ? KModuleMetaData.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public ProjectScreenModel load() {

loadPOM();
loadKModule();
loadGitURL();
loadImports();
loadWhiteList();
loadRepositories();
Expand All @@ -103,6 +104,17 @@ private void loadKModule() {
model.setPathToKModule(project.getKModuleXMLPath());
}

private void loadGitURL() {
String value = "";
try {
value = Paths.convert(project.getRootPath()).getFileSystem().toString();
} catch (final Exception ignore) {
//this is basically for tests that don't use git file system
}

model.setGitUrl(value.replace("\n", " | "));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that getFilesystem().toString() is returning multiple lines with 1 url per line? I find that a bit confusing.. Could you please point me to some code where we're setting URL to contain newline-separated URLs? I'd like to understand this better.

Also it would be nice to have a unit test for this new loading behavior here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has always been the behavior of the jgit getFilesystem().toString(), here link for the code: https://github.com/kiegroup/appformer/blob/master/uberfire-nio2-backport/uberfire-nio2-impls/uberfire-nio2-jgit/src/main/java/org/uberfire/java/nio/fs/jgit/JGitFileSystemImpl.java#L104-L117

About the test: yes... ideally the test should cover this, but to make this happen this test has to be completely redone to use git not "file://" - and to do this it wouldn't be possible for the release happening today. I'd prefer to have this quick and dirty fix merged to be part of the community release and then follow up and fix the test.

}

private void loadImports() {
model.setProjectImports(importsService.load(project.getImportsPath()));
model.setProjectImportsMetaData(getMetadata(project.getImportsPath()));
Expand Down