git/GitRepository.st
author vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
Mon, 10 Sep 2012 10:32:46 +0000
changeset 2 9731a2e41428
parent 1 8f4fde3c7129
child 3 2a4bf4fb54d8
permissions -rw-r--r--
- More API methods...

"{ Package: 'stx:libscm/git' }"

GitHandle subclass:#GitRepository
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:'GitObjectType'
	category:'Git-Model'
!


!GitRepository class methodsFor:'instance creation'!

open: aString
    | ref err |

    ref := ByteArray new: ExternalBytes sizeofPointer.
    err := GitPrimitives prim_git_repository_open: ref path: aString.
    err ~~ 0 ifTrue:[
        self error:'gitlib2 error'
    ].
    ^self new setAddressFromBytes:ref

    "Created: / 07-09-2012 / 23:45:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GitRepository class methodsFor:'accessing'!

structSize
    "Returns size of undelaying structure in bytes"

    ^0
! !

!GitRepository methodsFor:'finalization'!

basicFree
    GitPrimitives prim_git_object_free: self.

    "Created: / 08-09-2012 / 00:20:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GitRepository methodsFor:'lookup'!

lookup: oid
    "Lookup an object with given OID"
    ^self lookup: oid type: OBJ_ANY

    "Created: / 10-09-2012 / 10:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

lookup: oid type: typeId
    "Lookup an object with given OID"

    | ref err type obj |

    oid class == GitOid ifFalse:[
        self error: 'Passed oid is not a GitOid'.
        ^nil.
    ].
    ref := ByteArray new: ExternalBytes sizeofPointer.
    err := GitPrimitives prim_git_object_lookup: ref repo: self id: oid type: typeId.
    err ~~ 0 ifTrue:[
        self error:'gitlib2 error'
    ].
    typeId == OBJ_ANY ifTrue:[
        obj := ExternalAddress new setAddressFromBytes:ref.
        type := GitPrimitives prim_git_object_type: obj.
    ].
    ^GitObject type: type addressBytes: ref.

    "Created: / 10-09-2012 / 11:01:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GitRepository class methodsFor:'documentation'!

version_SVN
    ^ '$Id::                                                                                                                        $'
! !