Skip to content

Commit 3ff0eaa

Browse files
committed
Reworked closing Git repo after failed checkout
1 parent 6d16d7b commit 3ff0eaa

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/main/java/edu/kit/datamanager/mappingservice/util/FileUtil.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,18 @@ private static String guessFileExtension(String filename, byte[] fewKilobytesOfF
294294
public static Path cloneGitRepository(String repositoryUrl, String branch, String targetFolder) {
295295
File target = new File(targetFolder);
296296
if (target.exists()) {
297+
Git g = null;
297298
try {
298-
try (Git g = Git.open(target)) {
299-
LOGGER.trace("Repository already exists at {}. Active branch is: {}", target, g.getRepository().getBranch());
300-
g.getRepository().close();
301-
}
299+
g = Git.open(target);
300+
LOGGER.trace("Repository already exists at {}. Active branch is: {}", target, g.getRepository().getBranch());
302301
} catch (IOException e) {
303302
String message = String.format("Folder '%s' already exists but contains not Git repository.", target);
304303
LOGGER.error(message, e);
305304
throw new MappingServiceException("Failed to prepare plugin. Plugin code destination already exists but is empty.");
305+
} finally {
306+
if (g != null) {
307+
g.getRepository().close();
308+
}
306309
}
307310
} else {
308311
target.mkdirs();

src/main/resources/gemma.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=master
1+
version=v1.0.0
22
min.python=3.0.0

src/test/java/edu/kit/datamanager/mappingservice/rest/impl/MappingAdministrationControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class MappingAdministrationControllerTest {
9292

9393
private final static String TEMP_DIR_4_MAPPING = "/tmp/mapping-service/";
9494
private static final String MAPPING_ID = "my_dc";
95-
private static final String MAPPING_TYPE = "GEMMA_master";
95+
private static final String MAPPING_TYPE = "GEMMA_v1.0.0";
9696
private static final String MAPPING_TITLE = "TITEL";
9797
private static final String MAPPING_DESCRIPTION = "DESCRIPTION";
9898

0 commit comments

Comments
 (0)