You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/routers/api/v1/repo
Lunny Xiao 5f82ead13c
Simplify how git repositories are opened (#28937)
## Purpose
This is a refactor toward building an abstraction over managing git
repositories.
Afterwards, it does not matter anymore if they are stored on the local
disk or somewhere remote.

## What this PR changes
We used `git.OpenRepository` everywhere previously.
Now, we should split them into two distinct functions:

Firstly, there are temporary repositories which do not change:

```go
git.OpenRepository(ctx, diskPath)
```

Gitea managed repositories having a record in the database in the
`repository` table are moved into the new package `gitrepo`:

```go
gitrepo.OpenRepository(ctx, repo_model.Repo)
```

Why is `repo_model.Repository` the second parameter instead of file
path?
Because then we can easily adapt our repository storage strategy.
The repositories can be stored locally, however, they could just as well
be stored on a remote server.

## Further changes in other PRs
- A Git Command wrapper on package `gitrepo` could be created. i.e.
`NewCommand(ctx, repo_model.Repository, commands...)`. `git.RunOpts{Dir:
repo.RepoPath()}`, the directory should be empty before invoking this
method and it can be filled in the function only. #28940
- Remove the `RepoPath()`/`WikiPath()` functions to reduce the
possibility of mistakes.

---------

Co-authored-by: delvh <dev.lh@web.de>
1 year ago
..
action.go Refactor secrets modification logic (#26873) 1 year ago
avatar.go Add missing 404 response to Swagger (#27038) 1 year ago
blob.go Add missing 404 response to Swagger (#27038) 1 year ago
branch.go Simplify how git repositories are opened (#28937) 1 year ago
collaborators.go Move more functions to db.Find (#28419) 1 year ago
commits.go Filter get single commit (#24613) 2 years ago
file.go Simplify how git repositories are opened (#28937) 1 year ago
fork.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
git_hook.go Add missing 404 response to Swagger (#27038) 1 year ago
git_ref.go Implement FSFE REUSE for golang files (#21840) 2 years ago
hook.go Use db.Find instead of writing methods for every object (#28084) 1 year ago
hook_test.go Move web/api context related testing function into a separate package (#26859) 1 year ago
issue.go Fix comment permissions (#28213) 1 year ago
issue_attachment.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
issue_comment.go Fix comment permissions (#28213) 1 year ago
issue_comment_attachment.go Fix comment permissions (#28213) 1 year ago
issue_dependency.go Fix issue dependencies (#27736) 1 year ago
issue_label.go Don't let API add 2 exclusive labels from same scope (#27433) 1 year ago
issue_pin.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
issue_reaction.go Fix comment permissions (#28213) 1 year ago
issue_stopwatch.go Final round of `db.DefaultContext` refactor (#27587) 1 year ago
issue_subscription.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
issue_tracked_time.go Final round of `db.DefaultContext` refactor (#27587) 1 year ago
key.go Fix comment permissions (#28213) 1 year ago
label.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
language.go Implement FSFE REUSE for golang files (#21840) 2 years ago
main_test.go make writing main test easier (#27270) 1 year ago
migrate.go Remove unnecessary parameter (#27671) 1 year ago
milestone.go Second part of refactor `db.Find` (#28194) 1 year ago
mirror.go Refactor deletion (#28610) 1 year ago
notes.go Abstract hash function usage (#28138) 1 year ago
patch.go Updates to the API for archived repos (#27149) 1 year ago
pull.go Simplify how git repositories are opened (#28937) 1 year ago
pull_review.go Simplify how git repositories are opened (#28937) 1 year ago
release.go Move more functions to db.Find (#28419) 1 year ago
release_attachment.go Fix comment permissions (#28213) 1 year ago
release_tags.go Fix comment permissions (#28213) 1 year ago
repo.go Simplify how git repositories are opened (#28937) 1 year ago
repo_test.go Move web/api context related testing function into a separate package (#26859) 1 year ago
runners.go Add get actions runner registration token for API routes, repo, org, user and global level (#27144) 1 year ago
star.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
status.go Fix `GetCommitStatuses` (#28787) 1 year ago
subscriber.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
tag.go Fix comment permissions (#28213) 1 year ago
teams.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
topic.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
transfer.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
tree.go Add missing 404 response to Swagger (#27038) 1 year ago
wiki.go Simplify how git repositories are opened (#28937) 1 year ago