Skip to content

Commit 593d41e

Browse files
committed
remove initFixGitHome117rc
1 parent 2777d63 commit 593d41e

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

modules/git/git.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020

2121
"code.gitea.io/gitea/modules/log"
2222
"code.gitea.io/gitea/modules/setting"
23-
"code.gitea.io/gitea/modules/util"
24-
2523
"github.com/hashicorp/go-version"
2624
)
2725

@@ -168,51 +166,6 @@ func InitSimple(ctx context.Context) error {
168166

169167
var initOnce sync.Once
170168

171-
func initFixGitHome117rc() error {
172-
// Gitea 1.17-rc uses "setting.RepoRootPath" for Git HOME, which is incorrect.
173-
// Do this check to make sure there is no legacy file in the RepoRootPath. This check might be able to be removed with 1.18 release.
174-
175-
// remove the auto generated git config file (it will be moved to new home)
176-
gitConfigNewPath := filepath.Join(HomeDir(), ".gitconfig")
177-
gitConfigLegacyPath := filepath.Join(setting.RepoRootPath, ".gitconfig")
178-
if ok, err := util.IsExist(gitConfigLegacyPath); ok && err == nil {
179-
if err = os.MkdirAll(HomeDir(), os.ModePerm); err != nil {
180-
return err
181-
}
182-
if ok, err = util.IsExist(gitConfigNewPath); !ok && err == nil {
183-
err = util.CopyFile(gitConfigLegacyPath, gitConfigNewPath)
184-
} else {
185-
err = util.CopyFile(gitConfigLegacyPath, gitConfigNewPath+".bak")
186-
}
187-
if err != nil {
188-
return err
189-
}
190-
_ = os.Remove(gitConfigLegacyPath)
191-
}
192-
193-
// remove the empty directories, if some directories are non-empty, warn users and exit
194-
var hasCheckErr bool
195-
for _, wellKnownDirName := range []string{".ssh", ".gnupg"} {
196-
legacyDir := filepath.Join(setting.RepoRootPath, wellKnownDirName)
197-
st, err := os.Lstat(legacyDir) // only process dir or symlink
198-
if err != nil || (!st.IsDir() && st.Mode()&os.ModeSymlink != os.ModeSymlink) {
199-
continue
200-
}
201-
_ = os.Remove(legacyDir) // try to remove the empty dummy directory first
202-
_, err = os.Stat(legacyDir) // if the directory is not empty, then it won't be removed, it should be handled manually
203-
if err == nil || !errors.Is(err, os.ErrNotExist) {
204-
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`, legacyDir)
205-
hasCheckErr = true
206-
}
207-
}
208-
209-
if hasCheckErr {
210-
log.Fatal("Please fix errors above, remove legacy files.")
211-
}
212-
213-
return nil
214-
}
215-
216169
// InitOnceWithSync initializes git module with version check and change global variables, sync gitconfig.
217170
// This method will update the global variables ONLY ONCE (just like git.CheckLFSVersion -- which is not ideal too),
218171
// otherwise there will be data-race problem at the moment.
@@ -225,9 +178,6 @@ func InitOnceWithSync(ctx context.Context) (err error) {
225178
if err = InitSimple(ctx); err != nil {
226179
return
227180
}
228-
if err = initFixGitHome117rc(); err != nil {
229-
return
230-
}
231181

232182
// when git works with gnupg (commit signing), there should be a stable home for gnupg commands
233183
if _, ok := os.LookupEnv("GNUPGHOME"); !ok {

0 commit comments

Comments
 (0)