Give each const group a type
This allows us to restrict which constants the compiler will allow through, and makes the sorting in the documentation better.
This commit is contained in:
parent
00e3df94c7
commit
b5aca803db
|
@ -11,8 +11,9 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ReferenceType int
|
||||||
const (
|
const (
|
||||||
ReferenceSymbolic = C.GIT_REF_SYMBOLIC
|
ReferenceSymbolic ReferenceType = C.GIT_REF_SYMBOLIC
|
||||||
ReferenceOid = C.GIT_REF_OID
|
ReferenceOid = C.GIT_REF_OID
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -103,8 +104,8 @@ func (v *Reference) Name() string {
|
||||||
return C.GoString(C.git_reference_name(v.ptr))
|
return C.GoString(C.git_reference_name(v.ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Reference) Type() int {
|
func (v *Reference) Type() ReferenceType {
|
||||||
return int(C.git_reference_type(v.ptr))
|
return ReferenceType(C.git_reference_type(v.ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Reference) Free() {
|
func (v *Reference) Free() {
|
||||||
|
|
|
@ -144,7 +144,7 @@ func compareStringList(t *testing.T, expected, actual []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkRefType(t *testing.T, ref *Reference, kind int) {
|
func checkRefType(t *testing.T, ref *Reference, kind ReferenceType) {
|
||||||
if ref.Type() == kind {
|
if ref.Type() == kind {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
3
tree.go
3
tree.go
|
@ -13,8 +13,9 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Filemode int
|
||||||
const (
|
const (
|
||||||
FilemodeNew = C.GIT_FILEMODE_NEW
|
FilemodeNew Filemode = C.GIT_FILEMODE_NEW
|
||||||
FilemodeTree = C.GIT_FILEMODE_TREE
|
FilemodeTree = C.GIT_FILEMODE_TREE
|
||||||
FilemodeBlob = C.GIT_FILEMODE_BLOB
|
FilemodeBlob = C.GIT_FILEMODE_BLOB
|
||||||
FilemodeBlobExecutable = C.GIT_FILEMODE_BLOB_EXECUTABLE
|
FilemodeBlobExecutable = C.GIT_FILEMODE_BLOB_EXECUTABLE
|
||||||
|
|
5
walk.go
5
walk.go
|
@ -13,8 +13,9 @@ import (
|
||||||
|
|
||||||
// RevWalk
|
// RevWalk
|
||||||
|
|
||||||
|
type SortType uint
|
||||||
const (
|
const (
|
||||||
SortNone = C.GIT_SORT_NONE
|
SortNone SortType = C.GIT_SORT_NONE
|
||||||
SortTopological = C.GIT_SORT_TOPOLOGICAL
|
SortTopological = C.GIT_SORT_TOPOLOGICAL
|
||||||
SortTime = C.GIT_SORT_TIME
|
SortTime = C.GIT_SORT_TIME
|
||||||
SortReverse = C.GIT_SORT_REVERSE
|
SortReverse = C.GIT_SORT_REVERSE
|
||||||
|
@ -81,7 +82,7 @@ func (v *RevWalk) Iterate(fun RevWalkIterator) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *RevWalk) Sorting(sm uint) {
|
func (v *RevWalk) Sorting(sm SortType) {
|
||||||
C.git_revwalk_sorting(v.ptr, C.uint(sm))
|
C.git_revwalk_sorting(v.ptr, C.uint(sm))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue