0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-12 14:31:24 +01:00
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>
2024-01-27 21:09:51 +01:00
..
actions Fix incorrect action duration time when rerun the job before executed once (#28364) 2024-01-19 14:05:49 +00:00
setting Preserve BOM in web editor (#28935) 2024-01-27 18:02:51 +00:00
activity.go
attachment.go
blame.go Use information from previous blame parts (#28572) 2023-12-21 22:48:18 +01:00
branch.go Adjust object format interface (#28469) 2023-12-17 11:56:08 +00:00
cherry_pick.go
commit.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
compare.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
download.go
editor_test.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
editor.go Preserve BOM in web editor (#28935) 2024-01-27 18:02:51 +00:00
find.go
githttp_test.go
githttp.go Adjust object format interface (#28469) 2023-12-17 11:56:08 +00:00
helper_test.go
helper.go
issue_content_history.go Fix missing check (#28406) 2023-12-10 21:37:10 +02:00
issue_dependency.go
issue_label_test.go
issue_label.go
issue_lock.go
issue_pin.go Fix missing check (#28406) 2023-12-10 21:37:10 +02:00
issue_stopwatch.go
issue_test.go
issue_timetrack.go
issue_watch.go Revert adding htmx until we finaly decide to add it (#28879) 2024-01-21 21:42:35 +08:00
issue.go Add ability to see open and closed issues at the same time (#28757) 2024-01-15 15:07:22 +00:00
main_test.go
middlewares.go Fix viewing wiki commit on empty repo (#28040) 2023-11-14 19:42:23 +08:00
migrate.go
milestone.go Rework markup link rendering (#26745) 2024-01-15 08:49:24 +00:00
packages.go
patch.go
projects_test.go
projects.go Rework markup link rendering (#26745) 2024-01-15 08:49:24 +00:00
pull_review.go Don't reload timeline page when (un)resolving or replying conversation (#28654) 2024-01-24 03:26:28 +00:00
pull.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
release_test.go Move more functions to db.Find (#28419) 2024-01-15 02:19:25 +00:00
release.go Rework markup link rendering (#26745) 2024-01-15 08:49:24 +00:00
render.go Preserve BOM in web editor (#28935) 2024-01-27 18:02:51 +00:00
repo.go Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
search.go
topic.go
treelist.go
view_test.go
view.go Preserve BOM in web editor (#28935) 2024-01-27 18:02:51 +00:00
wiki_test.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
wiki.go Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00