github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/tree_blob.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 // Copyright 2015 The Gogs Authors. All rights reserved. 7 8 package git 9 10 // GetBlobByPath get the blob object according the path 11 func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) { 12 entry, err := t.GetTreeEntryByPath(relpath) 13 if err != nil { 14 return nil, err 15 } 16 17 if !entry.IsDir() && !entry.IsSubModule() { 18 return entry.Blob(), nil 19 } 20 21 return nil, ErrNotExist{"", relpath} 22 }