import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
}
static String identify(Repository git) {
- if (git instanceof DfsRepository) {
- return ((DfsRepository) git).getDescription().getRepositoryName();
- } else if (git.getDirectory() != null) {
- return git.getDirectory().getPath();
+ String identifier = git.getIdentifier();
+ if (identifier == null) {
+ return "unknown";
}
- return "unknown";
+ return identifier;
}
private ServletUtils() {
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/jgit/lib/Repository.java" type="org.eclipse.jgit.lib.Repository">
+ <filter id="336695337">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.lib.Repository"/>
+ <message_argument value="getIdentifier()"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/jgit/revwalk/ObjectWalk.java" type="org.eclipse.jgit.revwalk.ObjectWalk">
<filter comment="ignore the risk subclasses could define the same field and cause a name clash" id="336658481">
<message_arguments>
return config;
}
+ /** {@inheritDoc} */
+ @Override
+ public String getIdentifier() {
+ return getDescription().getRepositoryName();
+ }
+
/** {@inheritDoc} */
@Override
public void scanForRepoChanges() throws IOException {
return refs;
}
+ /** {@inheritDoc} */
+ @Override
+ public String getIdentifier() {
+ File directory = getDirectory();
+ if (directory != null) {
+ return directory.getPath();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
/** {@inheritDoc} */
@Override
public FileBasedConfig getConfig() {
return gitDir;
}
+ /**
+ * Get repository identifier.
+ *
+ * @return repository identifier. The returned identifier has to be unique
+ * within a given Git server.
+ * @since 5.4
+ */
+ public abstract String getIdentifier();
+
/**
* Get the object database which stores this repository's data.
*
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
-import java.io.File;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.PushCertificate.NonceStatus;
@Override
public synchronized String createNonce(Repository repo, long timestamp)
throws IllegalStateException {
- String path;
- if (repo instanceof DfsRepository) {
- path = ((DfsRepository) repo).getDescription().getRepositoryName();
- } else {
- File directory = repo.getDirectory();
- if (directory != null) {
- path = directory.getPath();
- } else {
- throw new IllegalStateException();
- }
- }
-
- String input = path + ":" + String.valueOf(timestamp); //$NON-NLS-1$
+ String input = repo.getIdentifier() + ":" + String.valueOf(timestamp); //$NON-NLS-1$
byte[] rawHmac = mac.doFinal(input.getBytes(UTF_8));
return Long.toString(timestamp) + "-" + toHex(rawHmac); //$NON-NLS-1$
}