-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor git module, make Gitea use internal git config #19732
Refactor git module, make Gitea use internal git config #19732
Conversation
810b24a
to
ea727f2
Compare
8894540
to
0e0bcda
Compare
0e0bcda
to
dac2594
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
44dd482
to
22d62bc
Compare
OK, almost done (ready for review). CI passes. The PR description has been updated with more details. |
This comment was marked as off-topic.
This comment was marked as off-topic.
There is a break if he has changed [user]
name = Gitea
email = [email protected] |
Yup. It's not enough to lock around |
I am working on it now. 2 choices:
|
Please be aware that massive refactors to the settings need to wait until after 1.17 is released. |
And if we complete context passing then we don't actually need concurrency - because the settings could be obtained from the context hierarchy. For example, the use of setting.AppURL etc. should just be obtainable from the context hierarchy |
Sure, it will be a small change for git module only, won't affect others.
I agree to use/pass the context as much as possible. However I do not think |
This is going off-topic but I'll put a few points here:
Why do we need to propagate the context?
The first argument to almost every function really needs to become I know that grates and feels like it's going back to Java like behaviour - and I expect that Go2 or Go3 is going to have to come up with some way to make this less omnipresent but the benefit of just accepting this will be immense. |
Agree with your points of views. The question in my mind is: what will the And I proposed a patch #19934 to resolve the data-race problem, it seems that it works, the first round test passes, now it's on the second round. |
* giteaoffical/main: Fix data-race problems in git module (quick patch) (go-gitea#19934) [skip ci] Updated translations via Crowdin Fix copy/paste of empty lines (go-gitea#19798) Normalize line endings in fomantic build files (go-gitea#19932) Make user profile image show full image on mobile (go-gitea#19840) Custom regexp external issues (go-gitea#17624) Use Golang 1.18 for Gitea 1.17 release (go-gitea#19918) Refactor git module, make Gitea use internal git config (go-gitea#19732) [skip ci] Updated translations via Crowdin
With go-gitea#19732, the default location for the `.gnupg` folder has changed. To mitigate this breaking change, users can specify the home directory for gnupg via `$GNUPGHOME` environment variable to keep using their current location.
Before, in go-gitea#19732, the old home directory is not correct. This PR introduces a new config option for git home: git.HOME_PATH, which is default to %(APP_DATA_PATH)/home And pass env GNUPGHOME to git command, force Gitea to use a stable GNUPGHOME directory
Before, in #19732, the old home directory is not correct. This PR introduces a new config option for git home: git.HOME_PATH, which is default to %(APP_DATA_PATH)/home And pass env GNUPGHOME to git command, force Gitea to use a stable GNUPGHOME directory
* Add hint for GNUPGHOME environment variable With #19732, the default location for the `.gnupg` folder has changed. To mitigate this breaking change, users can specify the home directory for gnupg via `$GNUPGHOME` environment variable to keep using their current location. * Update docs/content/doc/advanced/signing.en-us.md Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: John Olheiser <[email protected]> Co-authored-by: zeripath <[email protected]>
* Add hint for GNUPGHOME environment variable With go-gitea#19732, the default location for the `.gnupg` folder has changed. To mitigate this breaking change, users can specify the home directory for gnupg via `$GNUPGHOME` environment variable to keep using their current location. * Update docs/content/doc/advanced/signing.en-us.md Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: John Olheiser <[email protected]> Co-authored-by: zeripath <[email protected]>
* Refactor git module, make Gitea use internal git config, add safe.directory config * introduce git.InitSimple and git.InitWithConfigSync, make serv cmd use gitconfig * use HOME instead of GIT_CONFIG_GLOBAL, because git always needs a correct HOME * fix cmd env in cmd/serv.go * fine tune error message * Fix a incorrect test case * fix configAddNonExist * fix configAddNonExist logic, add `--fixed-value` flag, add tests * add configSetNonExist function in case it's needed. * use configSetNonExist for `user.name` and `user.email` * add some comments * Update cmd/serv.go Co-authored-by: zeripath <[email protected]> * Update cmd/serv.go Co-authored-by: zeripath <[email protected]> * Update modules/git/git.go Co-authored-by: zeripath <[email protected]> * Update modules/setting/setting.go Co-authored-by: zeripath <[email protected]> * Update modules/git/repo_attribute.go Co-authored-by: zeripath <[email protected]> * fix spaces in messages * use `configSet("core.protectNTFS", ...)` instead of `globalCommandArgs` * remove GIT_CONFIG_NOSYSTEM, continue to use system's git config * Update cmd/serv.go Co-authored-by: zeripath <[email protected]> * fix merge * remove code for safe.directory * separate git.CommonEnvs to CommonGitCmdEnvs and CommonCmdServEnvs * avoid Golang's data race error Co-authored-by: zeripath <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
Gitea 1.17.0 changed the Gitea user's home directory. See: go-gitea/gitea#20114 go-gitea/gitea#19732
Related issues
This PR implements #19709
Close #19709
Before, Gitea uses current user's
$HOME/.gitconfig
. The config may conflict, some config options may affect security, and it's difficult for Gitea to maintain its own config options.Details about this PR
/etc/gitconfig
) is still read and used at the moment.git config
related functions, add test code for them.git.LoadGitVersion
, in fact theCheckGitVersionAtLeast
already handles versions correctly.cmd/serv.go
didn't callgit.Init
, did't respect the git env. This PR makes the git module always be initialized and used.PrepareTestEnv
-like functions, they should be refactored later .....About
gogit
gogit
doesn't support customized gitconfig, luckily, at the moment,gogit
doesn't rely the gitconfig too muchSo it's fine to have this PR, no affecting on
gogit
side in my mind. And in the future,gogit
should be maintained separately, instead of mixing with native git.Backport or not
The git module code have changed a lot since 1.16, the backport would be
a littlequite dirty (update: I have a feeling it's too complex, it would change a lot of modules, not worth to be backported).Before: Gitea's git uses system gitconfig (
/etc/gitconfig
) and current user's global gitconfig ($HOME/.gitconfig
)After: Gitea's git uses system gitconfig (
/etc/gitconfig
) and internal customized global gitconfig. And, when running git, the HOME is set to its internal HOME.If you have your own customized config for git in Gitea, you should set these configs in
/etc/gitconfig
or the.gitconfig
in its HOME. All related home files for git command (like.gnupg
) should also be put in Gitea's git home directory.NOTICE, after #20114 , the
[git].HOME_PATH
will be used for Git HOME directory.