Skip to content

Commit 4d9caa0

Browse files
committed
Merge remote-tracking branch 'origin/master' into ui-tweaks
2 parents 7d4cae5 + 4ce9ffa commit 4d9caa0

File tree

16 files changed

+266
-60
lines changed

16 files changed

+266
-60
lines changed

NOTICE.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CWL Viewer
22
https://github.com/common-workflow-language/cwlviewer/
33

4-
* Copyright (c) 2016-2017 Mark Robinson http://orcid.org/0000-0002-8184-7507
5-
* Copyright (c) 2016-2017 The University of Manchester
4+
* Copyright (c) 2016-2017 Mark Robinson https://orcid.org/0000-0002-8184-7507
5+
* Copyright (c) 2016-2018 The University of Manchester
66

77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -32,8 +32,7 @@ This logo may be used only for attribution within the CWL Viewer project.
3232
img/BioExcel_logo_cropped.svg
3333
http://bioexcel.eu/
3434

35-
Distributed under a Creative Commons Attribution 4.0 license.
36-
https://creativecommons.org/licenses/by/4.0/
35+
Distributed under a [Creative Commons Attribution 4.0 license](https://creativecommons.org/licenses/by/4.0/)
3736

3837
-----------
3938

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
<artifactId>org.eclipse.jgit</artifactId>
104104
<version>4.8.0.201706111038-r</version>
105105
</dependency>
106+
<dependency>
107+
<groupId>org.mockito</groupId>
108+
<artifactId>mockito-all</artifactId>
109+
<version>1.10.19</version>
110+
<scope>test</scope>
111+
</dependency>
106112
</dependencies>
107113

108114
<build>

src/main/java/org/commonwl/view/git/GitService.java

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.commonwl.view.researchobject.HashableAgent;
2424
import org.eclipse.jgit.api.Git;
2525
import org.eclipse.jgit.api.errors.GitAPIException;
26+
import org.eclipse.jgit.api.errors.RefNotFoundException;
2627
import org.eclipse.jgit.lib.ObjectId;
2728
import org.eclipse.jgit.lib.PersonIdent;
2829
import org.eclipse.jgit.revwalk.RevCommit;
@@ -32,6 +33,7 @@
3233
import org.springframework.beans.factory.annotation.Value;
3334
import org.springframework.stereotype.Service;
3435

36+
import java.io.File;
3537
import java.io.IOException;
3638
import java.net.URI;
3739
import java.net.URISyntaxException;
@@ -67,7 +69,7 @@ public GitService(@Value("${gitStorage}") Path gitStorage,
6769
* Gets a repository, cloning into a local directory or
6870
* @param gitDetails The details of the Git repository
6971
* @param reuseDir Whether the cached repository can be used
70-
* @returns The git object for the repository
72+
* @return The git object for the repository
7173
*/
7274
public Git getRepository(GitDetails gitDetails, boolean reuseDir)
7375
throws GitAPIException, IOException {
@@ -84,34 +86,45 @@ public Git getRepository(GitDetails gitDetails, boolean reuseDir)
8486
} else {
8587
// Create a folder and clone repository into it
8688
Files.createDirectory(repoDir);
87-
repo = Git.cloneRepository()
88-
.setCloneSubmodules(cloneSubmodules)
89-
.setURI(gitDetails.getRepoUrl())
90-
.setDirectory(repoDir.toFile())
91-
.setCloneAllBranches(true)
92-
.call();
89+
repo = cloneRepo(gitDetails.getRepoUrl(), repoDir.toFile());
9390
}
9491
} else {
9592
// Another thread is already using the existing folder
9693
// Must create another temporary one
97-
repo = Git.cloneRepository()
98-
.setCloneSubmodules(cloneSubmodules)
99-
.setURI(gitDetails.getRepoUrl())
100-
.setDirectory(createTempDir())
101-
.setCloneAllBranches(true)
102-
.call();
94+
repo = cloneRepo(gitDetails.getRepoUrl(), createTempDir());
10395
}
10496

10597
// Checkout the specific branch or commit ID
10698
if (repo != null) {
10799
// Create a new local branch if it does not exist and not a commit ID
108100
String branchOrCommitId = gitDetails.getBranch();
109-
if (!ObjectId.isId(branchOrCommitId)) {
101+
final boolean isId = ObjectId.isId(branchOrCommitId);
102+
if (!isId) {
110103
branchOrCommitId = "refs/remotes/origin/" + branchOrCommitId;
111104
}
112-
repo.checkout()
113-
.setName(branchOrCommitId)
114-
.call();
105+
try {
106+
repo.checkout()
107+
.setName(branchOrCommitId)
108+
.call();
109+
}
110+
catch (Exception ex) {
111+
// Maybe it was a tag
112+
if (!isId && ex instanceof RefNotFoundException) {
113+
final String tag = gitDetails.getBranch();
114+
try {
115+
repo.checkout()
116+
.setName(tag)
117+
.call();
118+
}
119+
catch (Exception ex2) {
120+
// Throw the first exception, to keep the same behavior as before.
121+
throw ex;
122+
}
123+
}
124+
else {
125+
throw ex;
126+
}
127+
}
115128
}
116129

117130
return repo;
@@ -184,4 +197,19 @@ public GitDetails transferPathToBranch(GitDetails githubInfo) {
184197
}
185198
}
186199

200+
/**
201+
* Clones a Git repository
202+
* @param repoUrl the url of the Git repository
203+
* @param directory the directory to clone the repo into
204+
* @return a Git instance
205+
* @throws GitAPIException if any error occurs cloning the repo
206+
*/
207+
protected Git cloneRepo(String repoUrl, File directory) throws GitAPIException {
208+
return Git.cloneRepository()
209+
.setCloneSubmodules(cloneSubmodules)
210+
.setURI(repoUrl)
211+
.setDirectory(directory)
212+
.setCloneAllBranches(true)
213+
.call();
214+
}
187215
}

src/main/resources/static/css/main-20170616.css renamed to src/main/resources/static/css/main-20180518.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,20 @@ td.run, td.doc {
328328
#format-html {
329329
display: none;
330330
}
331+
/**
332+
* Workaround (not really) for
333+
* https://github.com/common-workflow-language/cwlviewer/issues/166
334+
*/
335+
#format-json {
336+
display: none;
337+
}
338+
339+
/**
340+
* Light email-obfuscation
341+
*/
342+
.obf-hide {
343+
display: none;
344+
}
345+
.obf-at::before {
346+
content: "@"
347+
}

0 commit comments

Comments
 (0)