@@ -24,6 +24,7 @@ import org.eclipse.jgit.api.Git
24
24
import org .eclipse .jgit .diff .DiffAlgorithm .SupportedAlgorithm
25
25
import org .eclipse .jgit .diff ._
26
26
import org .eclipse .jgit .internal .storage .file .ObjectDirectory
27
+ import org .eclipse .jgit .lib .Constants .OBJ_BLOB
27
28
import org .eclipse .jgit .lib .ObjectInserter .Formatter
28
29
import org .eclipse .jgit .lib .ObjectReader .OBJ_ANY
29
30
import org .eclipse .jgit .lib ._
@@ -42,7 +43,11 @@ package object git {
42
43
43
44
val ObjectFormatter = new Formatter
44
45
45
- def storeBlob (bytes : Array [Byte ])(implicit i : ObjectInserter ): ObjectId = i.insert(Constants .OBJ_BLOB , bytes)
46
+ implicit class RichByteArray (bytes : Array [Byte ]) {
47
+ lazy val blobId = ObjectFormatter .idFor(OBJ_BLOB , bytes)
48
+ }
49
+
50
+ def storeBlob (bytes : Array [Byte ])(implicit i : ObjectInserter ): ObjectId = i.insert(OBJ_BLOB , bytes)
46
51
47
52
def storeBlob (text : String )(implicit i : ObjectInserter , charset : Charset ): ObjectId = storeBlob(text.getBytes(charset))
48
53
@@ -188,7 +193,7 @@ package object git {
188
193
189
194
def isDiffableType (side : Side ) =
190
195
// diffEntry.getMode(side) != FileMode.GITLINK &&
191
- diffEntry.getId(side) != null && diffEntry.getMode(side).getObjectType == Constants . OBJ_BLOB
196
+ diffEntry.getId(side) != null && diffEntry.getMode(side).getObjectType == OBJ_BLOB
192
197
193
198
lazy val bothSidesDiffableType : Boolean = Side .values().map(isDiffableType).forall(d => d)
194
199
0 commit comments