|
21 | 21 | import svnserver.repository.VcsRepository;
|
22 | 22 |
|
23 | 23 | import java.io.File;
|
| 24 | +import java.io.FileNotFoundException; |
24 | 25 | import java.io.IOException;
|
25 | 26 | import java.io.InputStream;
|
26 | 27 | import java.nio.charset.StandardCharsets;
|
@@ -60,8 +61,11 @@ public class GitRepository implements VcsRepository {
|
60 | 61 | private final Map<String, String> cacheMd5 = new ConcurrentHashMap<>();
|
61 | 62 |
|
62 | 63 | public GitRepository(@NotNull RepositoryConfig config) throws IOException, SVNException {
|
63 |
| - this.repository = new FileRepository(new File(config.getPath()).getAbsolutePath()); |
| 64 | + this.repository = new FileRepository(new File(config.getPath()).getAbsoluteFile()); |
64 | 65 | log.info("Repository path: {}", repository.getDirectory());
|
| 66 | + if (!repository.getDirectory().exists()) { |
| 67 | + throw new FileNotFoundException(repository.getDirectory().getPath()); |
| 68 | + } |
65 | 69 | final Ref branchRef = repository.getRef(config.getBranch());
|
66 | 70 | if (branchRef == null) {
|
67 | 71 | throw new IOException("Branch not found: " + config.getBranch());
|
@@ -144,21 +148,6 @@ private void collectChanges(@NotNull Map<String, GitLogEntry> changes, @NotNull
|
144 | 148 | }
|
145 | 149 | }
|
146 | 150 |
|
147 |
| - private File findGitPath() { |
148 |
| - final File root = new File(".").getAbsoluteFile(); |
149 |
| - File path = root; |
150 |
| - while (true) { |
151 |
| - final File repo = new File(path, ".git"); |
152 |
| - if (repo.exists()) { |
153 |
| - return repo; |
154 |
| - } |
155 |
| - path = path.getParentFile(); |
156 |
| - if (path == null) { |
157 |
| - throw new IllegalStateException("Repository not found from directiry: " + root.getAbsolutePath()); |
158 |
| - } |
159 |
| - } |
160 |
| - } |
161 |
| - |
162 | 151 | @Override
|
163 | 152 | public int getLatestRevision() throws IOException {
|
164 | 153 | lock.readLock().lock();
|
|
0 commit comments