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/models
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
activities Simplify how git repositories are opened (#28937) 1 year ago
admin Next round of `db.DefaultContext` refactor (#27089) 1 year ago
asymkey Move more functions to db.Find (#28419) 1 year ago
auth Move more functions to db.Find (#28419) 1 year ago
avatars Refactor some legacy code and remove unused code (#28622) 1 year ago
db Move more functions to db.Find (#28419) 1 year ago
dbfs make writing main test easier (#27270) 1 year ago
fixtures Fix reverting a merge commit failing (#28794) 1 year ago
git Add support for sha256 repositories (#23894) 1 year ago
issues Simplify how git repositories are opened (#28937) 1 year ago
migrations Add support for sha256 repositories (#23894) 1 year ago
organization Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 1 year ago
packages Fix some RPM registry flaws (#28782) 1 year ago
perm Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 1 year ago
project Fix comment permissions (#28213) 1 year ago
pull Add support for sha256 repositories (#23894) 1 year ago
repo Simplify how git repositories are opened (#28937) 1 year ago
secret Use db.Find instead of writing methods for every object (#28084) 1 year ago
shared/types Display owner of a runner as a tooltip instead of static text (#24377) 2 years ago
system Refactor deletion (#28610) 1 year ago
unit Make actions default enabled for newly created repository if global configuraion enabled (#27482) 1 year ago
unittest Upgrade xorm (#27673) 1 year ago
user Forbid removing the last admin user (#28337) 1 year ago
webhook Refactor deletion (#28610) 1 year ago
error.go Forbid removing the last admin user (#28337) 1 year ago
fixture_generation.go Replace more db.DefaultContext (#27628) 1 year ago
fixture_test.go Replace more db.DefaultContext (#27628) 1 year ago
main_test.go make writing main test easier (#27270) 1 year ago
org.go Refactor deletion (#28610) 1 year ago
org_team.go Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 1 year ago
org_team_test.go Reduce usage of `db.DefaultContext` (#27073) 1 year ago
org_test.go Replace more db.DefaultContext (#27628) 1 year ago
repo.go Refactor deletion (#28610) 1 year ago
repo_test.go Penultimate round of `db.DefaultContext` refactor (#27414) 1 year ago
repo_transfer.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
repo_transfer_test.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago