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/web/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
..
actions Fix incorrect action duration time when rerun the job before executed once (#28364) 1 year ago
setting Preserve BOM in web editor (#28935) 1 year ago
activity.go
attachment.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
blame.go Use information from previous blame parts (#28572) 1 year ago
branch.go Adjust object format interface (#28469) 1 year ago
cherry_pick.go Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
commit.go Simplify how git repositories are opened (#28937) 1 year ago
compare.go Simplify how git repositories are opened (#28937) 1 year ago
download.go
editor.go Preserve BOM in web editor (#28935) 1 year ago
editor_test.go Simplify how git repositories are opened (#28937) 1 year ago
find.go
githttp.go Adjust object format interface (#28469) 1 year ago
githttp_test.go Fix http protocol auth (#27875) 1 year ago
helper.go Improve tree not found page (#26570) 1 year ago
helper_test.go
issue.go Add ability to see open and closed issues at the same time (#28757) 1 year ago
issue_content_history.go Fix missing check (#28406) 1 year ago
issue_dependency.go Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
issue_label.go Even more `db.DefaultContext` refactor (#27352) 1 year ago
issue_label_test.go Move web/api context related testing function into a separate package (#26859) 1 year ago
issue_lock.go Penultimate round of `db.DefaultContext` refactor (#27414) 1 year ago
issue_pin.go Fix missing check (#28406) 1 year ago
issue_stopwatch.go Final round of `db.DefaultContext` refactor (#27587) 1 year ago
issue_test.go
issue_timetrack.go Final round of `db.DefaultContext` refactor (#27587) 1 year ago
issue_watch.go Revert adding htmx until we finaly decide to add it (#28879) 1 year ago
main_test.go make writing main test easier (#27270) 1 year ago
middlewares.go Fix viewing wiki commit on empty repo (#28040) 1 year ago
migrate.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
milestone.go Rework markup link rendering (#26745) 1 year ago
packages.go Fix the display of org level badges (#26504) 1 year ago
patch.go Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
projects.go Rework markup link rendering (#26745) 1 year ago
projects_test.go Move web/api context related testing function into a separate package (#26859) 1 year ago
pull.go Simplify how git repositories are opened (#28937) 1 year ago
pull_review.go Don't reload timeline page when (un)resolving or replying conversation (#28654) 1 year ago
release.go Rework markup link rendering (#26745) 1 year ago
release_test.go Move more functions to db.Find (#28419) 1 year ago
render.go Preserve BOM in web editor (#28935) 1 year ago
repo.go Add support for sha256 repositories (#23894) 1 year ago
search.go
topic.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
treelist.go
view.go Preserve BOM in web editor (#28935) 1 year ago
view_test.go
wiki.go Simplify how git repositories are opened (#28937) 1 year ago
wiki_test.go Simplify how git repositories are opened (#28937) 1 year ago