forked from forgejo/forgejo
Fixes 4762 - Content API for Creating, Updating, Deleting Files (#6314)
This commit is contained in:
parent
059195b127
commit
2262811e40
54 changed files with 4154 additions and 563 deletions
|
@ -128,6 +128,21 @@ func (r *Repository) BranchNameSubURL() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// FileExists returns true if a file exists in the given repo branch
|
||||
func (r *Repository) FileExists(path string, branch string) (bool, error) {
|
||||
if branch == "" {
|
||||
branch = r.Repository.DefaultBranch
|
||||
}
|
||||
commit, err := r.GitRepo.GetBranchCommit(branch)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if _, err := commit.GetTreeEntryByPath(path); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetEditorconfig returns the .editorconfig definition if found in the
|
||||
// HEAD of the default repo branch.
|
||||
func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue