@@ -11,10 +11,9 @@ import (
11
11
"os"
12
12
"path"
13
13
"path/filepath"
14
+ "strconv"
14
15
"strings"
15
16
"time"
16
-
17
- "github.com/unknwon/com"
18
17
)
19
18
20
19
// Repository represents a Git repository.
@@ -251,6 +250,11 @@ const (
251
250
_STAT_SIZE_GARBAGE = "size-garbage: "
252
251
)
253
252
253
+ func strToInt64 (s string ) int64 {
254
+ i , _ := strconv .ParseInt (s , 10 , 64 )
255
+ return i
256
+ }
257
+
254
258
// GetRepoSize returns disk usage report of repository in given path.
255
259
func GetRepoSize (repoPath string ) (* CountObject , error ) {
256
260
cmd := NewCommand ("count-objects" , "-v" )
@@ -263,21 +267,21 @@ func GetRepoSize(repoPath string) (*CountObject, error) {
263
267
for _ , line := range strings .Split (stdout , "\n " ) {
264
268
switch {
265
269
case strings .HasPrefix (line , _STAT_COUNT ):
266
- countObject .Count = com . StrTo (line [7 :]). MustInt64 ( )
270
+ countObject .Count = strToInt64 (line [7 :])
267
271
case strings .HasPrefix (line , _STAT_SIZE ):
268
- countObject .Size = com . StrTo (line [6 :]). MustInt64 ( ) * 1024
272
+ countObject .Size = strToInt64 (line [6 :]) * 1024
269
273
case strings .HasPrefix (line , _STAT_IN_PACK ):
270
- countObject .InPack = com . StrTo (line [9 :]). MustInt64 ( )
274
+ countObject .InPack = strToInt64 (line [9 :])
271
275
case strings .HasPrefix (line , _STAT_PACKS ):
272
- countObject .Packs = com . StrTo (line [7 :]). MustInt64 ( )
276
+ countObject .Packs = strToInt64 (line [7 :])
273
277
case strings .HasPrefix (line , _STAT_SIZE_PACK ):
274
- countObject .SizePack = com . StrTo (line [11 :]). MustInt64 ( ) * 1024
278
+ countObject .SizePack = strToInt64 (line [11 :]) * 1024
275
279
case strings .HasPrefix (line , _STAT_PRUNE_PACKABLE ):
276
- countObject .PrunePackable = com . StrTo (line [16 :]). MustInt64 ( )
280
+ countObject .PrunePackable = strToInt64 (line [16 :])
277
281
case strings .HasPrefix (line , _STAT_GARBAGE ):
278
- countObject .Garbage = com . StrTo (line [9 :]). MustInt64 ( )
282
+ countObject .Garbage = strToInt64 (line [9 :])
279
283
case strings .HasPrefix (line , _STAT_SIZE_GARBAGE ):
280
- countObject .SizeGarbage = com . StrTo (line [14 :]). MustInt64 ( ) * 1024
284
+ countObject .SizeGarbage = strToInt64 (line [14 :]) * 1024
281
285
}
282
286
}
283
287
0 commit comments