ppkarwasz commented on PR #427:
URL: https://github.com/apache/commons-codec/pull/427#issuecomment-4137815770
@garydgregory,
What would you say about an API like the one below? It would have the
advantage of being reusable in other contexts. For example Commons Compress
could use it to compute a SWHID without extracting an archive.
```java
public final class GitId {
public enum FileMode {
/** Regular, non-executable file ({@code 100644}). */
REGULAR_FILE("100644"),
/** Executable file ({@code 100755}). */
EXECUTABLE_FILE("100755"),
/** Symbolic link ({@code 120000}). */
SYMBOLIC_LINK("120000"),
/** Directory / subtree ({@code 40000}). */
DIRECTORY("40000");
}
public static byte[] blobId(MessageDigest digest, byte[] content);
public static byte[] blobId(MessageDigest digest, InputStream input)
throws IOException;
public static byte[] blobId(MessageDigest digest, Path path) throws
IOException;
public static TreeBuilder treeBuilder(MessageDigest digest);
public static final class TreeBuilder {
public TreeBuilder addFile(String name, FileMode mode, byte[]
content);
public TreeBuilder addFile(String name, FileMode mode, InputStream
input) throws IOException;
public TreeBuilder addFile(String name, FileMode mode, Path path)
throws IOException;
public TreeBuilder addDirectory(String name, TreeBuilder subtree);
public byte[] build();
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]