gitea/modules
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 schedule tasks bugs (#28691) 2024-01-12 21:50:38 +00:00
activitypub
analyze
assetfs
auth
avatar
base Refactor some legacy code and remove unused code (#28622) 2023-12-28 09:38:59 +00:00
cache Always enable caches (#28527) 2023-12-19 09:29:05 +00:00
charset Preserve BOM in web editor (#28935) 2024-01-27 18:02:51 +00:00
container
context Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
contexttest Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
csv
emoji
eventsource
generate
git Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
gitgraph
gitrepo Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
graceful Suggest to use Type=simple for systemd service (#28717) 2024-01-07 15:18:04 +00:00
hcaptcha
highlight Add option to disable ambiguous unicode characters detection (#28454) 2023-12-17 14:38:54 +00:00
hostmatcher
html
httpcache
httplib
indexer Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
issue/template
json
label
lfs Do not set Accept header twice (#28598) 2023-12-28 03:59:00 +00:00
log
markup Strip / from relative links (#28932) 2024-01-27 11:36:01 +08:00
mcaptcha
metrics
migration
nosql
options
packages Use new RPM constants (#28931) 2024-01-25 21:40:24 +00:00
paginator
pprof
private Return responseText instead of string in some functions (#28836) 2024-01-19 10:45:23 +08:00
process
proxy
proxyprotocol
public Refactor CORS handler (#28587) 2023-12-25 20:13:18 +08:00
queue
recaptcha
references Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
regexplru
repository Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
secret
session
setting Fix incorrect PostgreSQL connection string for Unix sockets (#28865) 2024-01-20 16:04:47 +00:00
sitemap
ssh
storage
structs Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
svg
sync
system
templates Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
test
testlogger
timeutil Make template DateTime show proper tooltip (#28677) 2024-01-02 20:09:18 +01:00
translation
turnstile
typesniffer
updatechecker
upload
uri
user
util Fix some RPM registry flaws (#28782) 2024-01-19 11:37:10 +00:00
validation
web Refactor CORS handler (#28587) 2023-12-25 20:13:18 +08:00
webhook Fix schedule tasks bugs (#28691) 2024-01-12 21:50:38 +00:00