1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. 22 * Copyright (c) 2010, Trond Norbye <trond.norbye@gmail.com>. All rights reserved. 23 * Portions Copyright (c) 2018, Chris Fraire <cfraire@me.com>. 24 */ 25 package org.opengrok.indexer.history; 26 27 import java.io.File; 28 import java.io.IOException; 29 import java.io.OutputStream; 30 31 import org.opengrok.indexer.configuration.CommandTimeoutType; 32 33 /** 34 * Access to a Git repository. 35 * 36 * @author Trond Norbye <trond.norbye@gmail.com> 37 */ 38 public class RepoRepository extends Repository { 39 // TODO: cache all of the GitRepositories within the class 40 41 private static final long serialVersionUID = 1L; 42 /** 43 * The property name used to obtain the client command for this repository. 44 */ 45 public static final String CMD_PROPERTY_KEY = "org.opengrok.indexer.history.repo"; 46 /** 47 * The command to use to access the repository if none was given explicitly. 48 */ 49 public static final String CMD_FALLBACK = "repo"; 50 RepoRepository()51 public RepoRepository() { 52 type = "repo"; 53 setWorking(Boolean.TRUE); 54 55 ignoredDirs.add(".repo"); 56 } 57 58 @Override isWorking()59 public boolean isWorking() { 60 ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK); 61 return true; 62 } 63 64 @Override isRepositoryFor(File file, CommandTimeoutType cmdType)65 boolean isRepositoryFor(File file, CommandTimeoutType cmdType) { 66 if (file.isDirectory()) { 67 File f = new File(file, ".repo"); 68 return f.exists() && f.isDirectory(); 69 } 70 return false; 71 } 72 73 @Override supportsSubRepositories()74 boolean supportsSubRepositories() { 75 return true; 76 } 77 78 @Override fileHasHistory(File file)79 boolean fileHasHistory(File file) { 80 return false; 81 } 82 83 @Override hasHistoryForDirectories()84 boolean hasHistoryForDirectories() { 85 return false; 86 } 87 88 @Override getHistory(File file)89 History getHistory(File file) { 90 throw new UnsupportedOperationException("Should never be called!"); 91 } 92 93 @Override getHistoryGet(OutputStream out, String parent, String basename, String rev)94 boolean getHistoryGet(OutputStream out, String parent, String basename, String rev) { 95 throw new UnsupportedOperationException("Should never be called!"); 96 } 97 98 @Override fileHasAnnotation(File file)99 boolean fileHasAnnotation(File file) { 100 return false; 101 } 102 103 @Override annotate(File file, String revision)104 Annotation annotate(File file, String revision) { 105 throw new UnsupportedOperationException("Should never be called!"); 106 } 107 108 @Override determineParent(CommandTimeoutType cmdType)109 String determineParent(CommandTimeoutType cmdType) throws IOException { 110 return null; 111 } 112 113 @Override determineBranch(CommandTimeoutType cmdType)114 String determineBranch(CommandTimeoutType cmdType) { 115 return null; 116 } 117 118 @Override determineCurrentVersion(CommandTimeoutType cmdType)119 String determineCurrentVersion(CommandTimeoutType cmdType) throws IOException { 120 return null; 121 } 122 } 123