in src/main/scala/com/adamnfish/eek/sourcecode/Github.scala [113:137]
def blobToDocsFile[F[_]: MonadThrow](
path: String,
blobContent: BlobContent
): F[DocsFile] = {
(blobContent.encoding match {
case Some("base64") =>
MonadThrow[F].fromOption(
blobContent.content.map(c =>
new String(Base64.getMimeDecoder.decode(c))
),
new RuntimeException(s"Empty file at path `$path`")
)
case Some("utf-8") =>
MonadThrow[F].fromOption(
blobContent.content,
new RuntimeException(s"Empty file at path `$path`")
)
case encoding =>
MonadThrow[F].raiseError(
new RuntimeException(
s"Unsupported $encoding for file at path `$path` (gitsha:${blobContent.sha})"
)
)
}).map(DocsFile(path, _))
}