mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-05 04:55:50 +01:00
Use constant from jgit
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.common.io.ByteStreams;
|
||||
import org.eclipse.jgit.attributes.FilterCommand;
|
||||
import org.eclipse.jgit.lfs.LfsPointer;
|
||||
import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
|
||||
import org.eclipse.jgit.lfs.lib.Constants;
|
||||
import org.eclipse.jgit.lfs.lib.LongObjectId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -17,10 +18,6 @@ import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import static org.eclipse.jgit.lfs.lib.Constants.LONG_HASH_FUNCTION;
|
||||
|
||||
/**
|
||||
* Adapted version of JGit's {@link org.eclipse.jgit.lfs.CleanFilter} to write the
|
||||
@@ -75,21 +72,12 @@ class LfsBlobStoreCleanFilter extends FilterCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress warning for RuntimeException after check for wrong size, because hash alg for sha256 is built in
|
||||
@SuppressWarnings("squid:S00112")
|
||||
private DigestOutputStream createDigestStream() {
|
||||
MessageDigest md ;
|
||||
try {
|
||||
md = MessageDigest.getInstance(LONG_HASH_FUNCTION);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// Yes there is such a hash function (should be sha256)
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return new DigestOutputStream(new OutputStream() {
|
||||
@Override
|
||||
public void write(int b) {
|
||||
// no further target here, we are just interested in the digest
|
||||
}
|
||||
}, md);
|
||||
}, Constants.newMessageDigest());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user