您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

tree_blob.go 551B

1234567891011121314151617181920
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 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. package git
  6. // GetBlobByPath get the blob object according the path
  7. func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) {
  8. entry, err := t.GetTreeEntryByPath(relpath)
  9. if err != nil {
  10. return nil, err
  11. }
  12. if !entry.IsDir() && !entry.IsSubModule() {
  13. return entry.Blob(), nil
  14. }
  15. return nil, ErrNotExist{"", relpath}
  16. }