1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-01 08:55:47 +00:00
gitea/models
wxiaoguang 2cdf260f42
Refactor path & config system (#25330)
# The problem

There were many "path tricks":

* By default, Gitea uses its program directory as its work path
* Gitea tries to use the "work path" to guess its "custom path" and
"custom conf (app.ini)"
* Users might want to use other directories as work path
* The non-default work path should be passed to Gitea by GITEA_WORK_DIR
or "--work-path"
* But some Gitea processes are started without these values
    * The "serv" process started by OpenSSH server
    * The CLI sub-commands started by site admin
* The paths are guessed by SetCustomPathAndConf again and again
* The default values of "work path / custom path / custom conf" can be
changed when compiling

# The solution

* Use `InitWorkPathAndCommonConfig` to handle these path tricks, and use
test code to cover its behaviors.
* When Gitea's web server runs, write the WORK_PATH to "app.ini", this
value must be the most correct one, because if this value is not right,
users would find that the web UI doesn't work and then they should be
able to fix it.
* Then all other sub-commands can use the WORK_PATH in app.ini to
initialize their paths.
* By the way, when Gitea starts for git protocol, it shouldn't output
any log, otherwise the git protocol gets broken and client blocks
forever.

The "work path" priority is: WORK_PATH in app.ini > cmd arg --work-path
> env var GITEA_WORK_DIR > builtin default

The "app.ini" searching order is: cmd arg --config > cmd arg "work path
/ custom path" > env var "work path / custom path" > builtin default


## ⚠️ BREAKING

If your instance's "work path / custom path / custom conf" doesn't meet
the requirements (eg: work path must be absolute), Gitea will report a
fatal error and exit. You need to set these values according to the
error log.



----

Close #24818
Close #24222
Close #21606
Close #21498
Close #25107
Close #24981
Maybe close #24503

Replace #23301
Replace #22754

And maybe more
2023-06-21 13:50:26 +08:00
..
actions Add actor and status dropdowns to run list (#25118) 2023-06-21 04:25:14 +00:00
activities Use a separate admin page to show global stats, remove actions stat (#25062) 2023-06-03 22:03:41 +08:00
admin Make repo migration cancelable and fix various bugs (#24605) 2023-05-11 08:25:46 +00:00
asymkey Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
auth Add ability to set multiple redirect URIs in OAuth application UI (#25072) 2023-06-05 15:00:12 +08:00
avatars Avoid warning for system setting when start up (#23054) 2023-02-24 18:23:13 +08:00
db Fix index generation parallelly failure (#25235) 2023-06-15 02:14:43 +02:00
dbfs Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
fixtures Fix duplicate Reviewed-by trailers (#24796) 2023-06-09 16:34:49 +02:00
git Fix index generation parallelly failure (#25235) 2023-06-15 02:14:43 +02:00
issues Refactor: TotalTimest return seconds (#25370) 2023-06-19 18:40:06 +02:00
migrations Refactor path & config system (#25330) 2023-06-21 13:50:26 +08:00
organization Use RepositoryList instead of []*Repository (#25074) 2023-06-05 15:25:47 +08:00
packages Hide limited users if viewed by anonymous ghost (#25214) 2023-06-13 11:21:11 +08:00
perm Rewrite logger system (#24726) 2023-05-21 22:35:11 +00:00
project Improve GetBoards and getDefaultBoard (#22981) 2023-04-09 22:07:23 +08:00
pull refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo Remove stars when repo goes private (#19904) 2023-06-05 13:25:43 +00:00
secret Support configuration variables on Gitea Actions (#24724) 2023-06-20 22:54:15 +00:00
shared/types Display owner of a runner as a tooltip instead of static text (#24377) 2023-05-12 08:43:27 +00:00
system Avoid warning for system setting when start up (#23054) 2023-02-24 18:23:13 +08:00
unit Rewrite logger system (#24726) 2023-05-21 22:35:11 +00:00
unittest Refactor path & config system (#25330) 2023-06-21 13:50:26 +08:00
user Show bot label next to username when rendering autor link if the user is a bot (#24943) 2023-05-26 18:58:11 +02:00
webhook New webhook trigger for receiving Pull Request review requests (#24481) 2023-05-24 22:06:27 -04:00
error.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
fixture_generation.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
fixture_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
main_test.go Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
migrate_test.go Check primary keys for all tables and drop ForeignReference (#21721) 2022-12-23 19:35:43 +08:00
migrate.go Check primary keys for all tables and drop ForeignReference (#21721) 2022-12-23 19:35:43 +08:00
org_team_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
org_team.go Remove org users who belong to no teams (#24247) 2023-04-24 15:52:38 -04:00
org_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
org.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo_collaboration_test.go Rename repo.GetOwner to repo.LoadOwner (#22967) 2023-02-18 20:11:03 +08:00
repo_collaboration.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
repo_transfer_test.go Rename almost all Ctx functions (#22071) 2022-12-10 10:46:31 +08:00
repo_transfer.go Fix unclear IsRepositoryExist logic (#24374) 2023-04-28 14:14:26 -04:00
repo.go Implement actions artifacts (#22738) 2023-05-19 21:37:57 +08:00