forgejo-aneksajo_auto_patch.../data/54/new_aneksajo.diff
2025-01-23 01:26:39 +01:00

53 lines
1.5 KiB
Diff

15d14
< "regexp"
21a21
> "code.gitea.io/gitea/modules/ssh"
36c36
< pubkey, privkey, err := util.GenerateSSHKeypair()
---
> err = ssh.GenKeyPair(keyFile)
38,39d37
< require.NoError(t, os.WriteFile(keyFile, privkey, 0o600))
< require.NoError(t, os.WriteFile(keyFile+".pub", pubkey, 0o600))
44a43,64
> // reset ssh wrapper afterwards
> _gitSSH, gitSSHExists := os.LookupEnv("GIT_SSH")
> defer func() {
> if gitSSHExists {
> os.Setenv("GIT_SSH", _gitSSH)
> }
> }()
>
> _gitSSHCommand, gitSSHCommandExists := os.LookupEnv("GIT_SSH_COMMAND")
> defer func() {
> if gitSSHCommandExists {
> os.Setenv("GIT_SSH_COMMAND", _gitSSHCommand)
> }
> }()
>
> _gitSSHVariant, gitSSHVariantExists := os.LookupEnv("GIT_SSH_VARIANT")
> defer func() {
> if gitSSHVariantExists {
> os.Setenv("GIT_SSH_VARIANT", _gitSSHVariant)
> }
> }()
>
53a74,80
> func createHTTPUrl(gitPath string, u *url.URL) *url.URL {
> // this assumes u contains the HTTP base URL that Gitea is running on
> u2 := *u
> u2.Path = gitPath
> return &u2
> }
>
63,64d89
< var rootPathRe = regexp.MustCompile("\\[repository\\]\nROOT\\s=\\s.*")
<
83,87d107
< // Override repository root in config.
< conf, err := os.ReadFile(setting.CustomConf)
< require.NoError(t, err)
< require.NoError(t, os.WriteFile(setting.CustomConf, rootPathRe.ReplaceAll(conf, []byte("[repository]\nROOT = "+setting.RepoRootPath)), 0o600))
<
89d108
< require.NoError(t, os.WriteFile(setting.CustomConf, conf, 0o600))