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 6package git 7 8// GetBlobByPath get the blob object according the path 9func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) { 10 entry, err := t.GetTreeEntryByPath(relpath) 11 if err != nil { 12 return nil, err 13 } 14 15 if !entry.IsDir() && !entry.IsSubModule() { 16 return entry.Blob(), nil 17 } 18 19 return nil, ErrNotExist{"", relpath} 20} 21