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/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>
1 year ago
..
actions Fix schedule tasks bugs (#28691) 1 year ago
activitypub Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
analyze Rename code_langauge.go to code_language.go (#26377) 2 years ago
assetfs Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804) 1 year ago
auth Next round of `db.DefaultContext` refactor (#27089) 1 year ago
avatar Remove nfnt/resize and oliamb/cutter (#25999) 2 years ago
base Refactor some legacy code and remove unused code (#28622) 1 year ago
cache Always enable caches (#28527) 1 year ago
charset Preserve BOM in web editor (#28935) 1 year ago
container
context Simplify how git repositories are opened (#28937) 1 year ago
contexttest Simplify how git repositories are opened (#28937) 1 year ago
csv Refactor locale number (#24134) 2 years ago
emoji Update emoji set to Unicode 15 (#25595) 2 years ago
eventsource Final round of `db.DefaultContext` refactor (#27587) 1 year ago
generate Handle base64 decoding correctly to avoid panic (#26483) 1 year ago
git Simplify how git repositories are opened (#28937) 1 year ago
gitgraph More `db.DefaultContext` refactor (#27265) 1 year ago
gitrepo Simplify how git repositories are opened (#28937) 1 year ago
graceful Suggest to use Type=simple for systemd service (#28717) 1 year ago
hcaptcha
highlight Add option to disable ambiguous unicode characters detection (#28454) 1 year ago
hostmatcher Support allowed hosts for webhook to work with proxy (#27655) 1 year ago
html Refactor backend SVG package and add tests (#26335) 2 years ago
httpcache Less naked returns (#25713) 2 years ago
httplib Less naked returns (#25713) 2 years ago
indexer Simplify how git repositories are opened (#28937) 1 year ago
issue/template Replace `interface{}` with `any` (#25686) 2 years ago
json Replace `interface{}` with `any` (#25686) 2 years ago
label
lfs Do not set `Accept` header twice (#28598) 1 year ago
log Reduce some allocations in type conversion (#26772) 1 year ago
markup Strip `/` from relative links (#28932) 1 year ago
mcaptcha
metrics Reduce usage of `db.DefaultContext` (#27073) 1 year ago
migration Replace `interface{}` with `any` (#25686) 2 years ago
nosql Update tool dependencies, lock govulncheck and actionlint (#25655) 2 years ago
options Use a general approach to access custom/static/builtin assets (#24022) 2 years ago
packages Use new RPM constants (#28931) 1 year ago
paginator Use more specific test methods (#24265) 2 years ago
pprof
private Return `responseText` instead of string in some functions (#28836) 1 year ago
process Replace assert.Fail with assert.FailNow (#27578) 1 year ago
proxy
proxyprotocol
public Refactor CORS handler (#28587) 1 year ago
queue Increase queue length (#27555) 1 year ago
recaptcha
references Add support for sha256 repositories (#23894) 1 year ago
regexplru Upgrade go dependencies (#25819) 2 years ago
repository Simplify how git repositories are opened (#28937) 1 year ago
secret Improve decryption failure message (#24573) 2 years ago
session Next round of `db.DefaultContext` refactor (#27089) 1 year ago
setting Fix incorrect PostgreSQL connection string for Unix sockets (#28865) 1 year ago
sitemap
ssh Remove SSH workaround (#27893) 1 year ago
storage Fix object storage path handling (#27024) 1 year ago
structs Add support for sha256 repositories (#23894) 1 year ago
svg Refactor backend SVG package and add tests (#26335) 2 years ago
sync
system Replace more db.DefaultContext (#27628) 1 year ago
templates Add support for sha256 repositories (#23894) 1 year ago
test Move web/api context related testing function into a separate package (#26859) 1 year ago
testlogger Replace `interface{}` with `any` (#25686) 2 years ago
timeutil Make template `DateTime` show proper tooltip (#28677) 1 year ago
translation Replace `interface{}` with `any` (#25686) 2 years ago
turnstile
typesniffer Detect ogg mime-type as audio or video (#26494) 1 year ago
updatechecker Replace more db.DefaultContext (#27628) 1 year ago
upload
uri
user
util Fix some RPM registry flaws (#28782) 1 year ago
validation Check blocklist for emails when adding them to account (#26812) 1 year ago
web Refactor CORS handler (#28587) 1 year ago
webhook Fix schedule tasks bugs (#28691) 1 year ago