You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tree_blob.go 479B

12345678910111213141516171819
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // SPDX-License-Identifier: MIT
  4. package git
  5. // GetBlobByPath get the blob object according the path
  6. func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) {
  7. entry, err := t.GetTreeEntryByPath(relpath)
  8. if err != nil {
  9. return nil, err
  10. }
  11. if !entry.IsDir() && !entry.IsSubModule() {
  12. return entry.Blob(), nil
  13. }
  14. return nil, ErrNotExist{"", relpath}
  15. }