File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "fmt"
1212 "os"
1313 "os/exec"
14+ "path/filepath"
1415 "regexp"
1516 "runtime"
1617 "strings"
@@ -180,6 +181,24 @@ func InitOnceWithSync(ctx context.Context) (err error) {
180181 return
181182 }
182183
184+ // Gitea 1.17-rc uses "setting.RepoRootPath" for Git HOME, which is incorrect.
185+ // Do this check to make sure there is no legacy file in the RepoRootPath. This check might be able to be removed with 1.19 release.
186+ var hasCheckErr bool
187+ _ = os .Remove (filepath .Join (setting .RepoRootPath , ".gitconfig" )) // remove the auto generated git config file
188+ _ = os .Remove (filepath .Join (setting .RepoRootPath , ".ssh" )) // remove the empty dummy ".ssh" directory
189+ for _ , wellKnownName := range []string {".ssh" , ".gnupg" } {
190+ checkLegacyFile := filepath .Join (setting .RepoRootPath , wellKnownName )
191+ _ , checkErr := os .Stat (checkLegacyFile )
192+ if checkErr == nil || ! errors .Is (checkErr , os .ErrNotExist ) {
193+ log .Error (`Git HOME has been moved to [git].HOME_PATH, but there are legacy file in old place. Please backup and remove the legacy files %q` , checkLegacyFile )
194+ hasCheckErr = true
195+ }
196+ }
197+ if hasCheckErr {
198+ log .Fatal ("Please fix errors above, remove legacy files" )
199+ }
200+ // end of legacy Gitea 1.17-rc check
201+
183202 // Since git wire protocol has been released from git v2.18
184203 if setting .Git .EnableAutoGitWireProtocol && CheckGitVersionAtLeast ("2.18" ) == nil {
185204 globalCommandArgs = append (globalCommandArgs , "-c" , "protocol.version=2" )
You can’t perform that action at this time.
0 commit comments