From 7d3a31514afbe88664081b4ea57cd7939de99014 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 03 Jul 2014 17:00:40 -0400
Subject: [PATCH] Extract services manager into a top-level injectable manager
---
src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java b/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
index b203d47..c49d23b 100644
--- a/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009 The Android Open Source Project
* Copyright 2014 gitblit.com.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,10 +30,6 @@
import com.gitblit.transport.ssh.SshDaemonClient;
import com.gitblit.transport.ssh.commands.BaseCommand;
-/**
- * @author Eric Myhre
- *
- */
abstract class BaseGitCommand extends BaseCommand {
@Argument(index = 0, metaVar = "REPOSITORY", required = true, usage = "repository name")
protected String repository;
@@ -42,6 +39,16 @@
protected UploadPackFactory<SshDaemonClient> uploadPackFactory;
protected Repository repo;
+
+ @Override
+ public void destroy() {
+ super.destroy();
+
+ repositoryResolver = null;
+ receivePackFactory = null;
+ uploadPackFactory = null;
+ repo = null;
+ }
@Override
public void start(final Environment env) {
@@ -79,12 +86,11 @@
repository = repository.replace('\\', '/');
// ssh://git@thishost/path should always be name="/path" here
//
- if (!repository.startsWith("/")) {
- throw new Failure(1, "fatal: '" + repository + "': not starts with / character");
+ if (repository.startsWith("/")) {
+ repository = repository.substring(1);
}
- repository = repository.substring(1);
try {
- return repositoryResolver.open(ctx.getClient(), repository);
+ return repositoryResolver.open(getContext().getClient(), repository);
} catch (Exception e) {
throw new Failure(1, "fatal: '" + repository + "': not a git archive", e);
}
--
Gitblit v1.9.1