Add Filemode to TreeEntry
This field was missing, so let's add it, and let's add the const definitions for the modes while we're here.
This commit is contained in:
parent
22f43840aa
commit
3cbfdf37f4
|
@ -33,10 +33,15 @@ func TestObjectPoymorphism(t *testing.T) {
|
|||
t.Fatalf("Converting back to *Tree is not ok")
|
||||
}
|
||||
|
||||
if tree2.EntryByName("README") == nil {
|
||||
entry := tree2.EntryByName("README")
|
||||
if entry == nil {
|
||||
t.Fatalf("Tree did not have expected \"README\" entry")
|
||||
}
|
||||
|
||||
if entry.Filemode != FilemodeBlob {
|
||||
t.Fatal("Wrong filemode for \"README\"")
|
||||
}
|
||||
|
||||
_, ok = obj.(*Commit)
|
||||
if ok {
|
||||
t.Fatalf("*Tree is somehow the same as *Commit")
|
||||
|
|
11
tree.go
11
tree.go
|
@ -13,6 +13,15 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
FilemodeNew = C.GIT_FILEMODE_NEW
|
||||
FilemodeTree = C.GIT_FILEMODE_TREE
|
||||
FilemodeBlob = C.GIT_FILEMODE_BLOB
|
||||
FilemodeBlobExecutable = C.GIT_FILEMODE_BLOB_EXECUTABLE
|
||||
FilemodeLink = C.GIT_FILEMODE_LINK
|
||||
FilemodeCommit = C.GIT_FILEMODE_COMMIT
|
||||
)
|
||||
|
||||
type Tree struct {
|
||||
gitObject
|
||||
}
|
||||
|
@ -21,6 +30,7 @@ type TreeEntry struct {
|
|||
Name string
|
||||
Id *Oid
|
||||
Type ObjectType
|
||||
Filemode int
|
||||
}
|
||||
|
||||
func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
|
||||
|
@ -28,6 +38,7 @@ func newTreeEntry(entry *C.git_tree_entry) *TreeEntry {
|
|||
C.GoString(C.git_tree_entry_name(entry)),
|
||||
newOidFromC(C.git_tree_entry_id(entry)),
|
||||
ObjectType(C.git_tree_entry_type(entry)),
|
||||
int(C.git_tree_entry_filemode(entry)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue