1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-05 15:15:49 +02:00

Save patch files in TempDir

This commit is contained in:
Ryooooooga 2021-09-27 22:39:20 +09:00 committed by Jesse Duffield
parent c8e9d1b4fc
commit 663c036ca5
2 changed files with 10 additions and 1 deletions

View File

@ -224,7 +224,7 @@ func (c *GitCommand) WorktreeFileDiffCmdStr(node models.IFile, plain bool, cache
}
func (c *GitCommand) ApplyPatch(patch string, flags ...string) error {
filepath := filepath.Join(c.Config.GetUserConfigDir(), utils.GetCurrentRepoName(), time.Now().Format("Jan _2 15.04.05.000000000")+".patch")
filepath := filepath.Join(c.Config.GetTempDir(), utils.GetCurrentRepoName(), time.Now().Format("Jan _2 15.04.05.000000000")+".patch")
c.Log.Infof("saving temporary patch to %s", filepath)
if err := c.OSCommand.CreateFileWithContent(filepath, patch); err != nil {
return err

View File

@ -21,6 +21,7 @@ type AppConfig struct {
UserConfig *UserConfig
UserConfigDir string
UserConfigPath string
TempDir string
AppState *AppState
IsNewRepo bool
}
@ -37,6 +38,7 @@ type AppConfigurer interface {
GetUserConfig() *UserConfig
GetUserConfigDir() string
GetUserConfigPath() string
GetTempDir() string
GetAppState() *AppState
SaveAppState() error
SetIsNewRepo(bool)
@ -60,6 +62,8 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg
debuggingFlag = true
}
tempDir := filepath.Join(os.TempDir(), "lazygit")
appState, err := loadAppState()
if err != nil {
return nil, err
@ -75,6 +79,7 @@ func NewAppConfig(name, version, commit, date string, buildSource string, debugg
UserConfig: userConfig,
UserConfigDir: configDir,
UserConfigPath: filepath.Join(configDir, "config.yml"),
TempDir: tempDir,
AppState: appState,
IsNewRepo: false,
}
@ -204,6 +209,10 @@ func (c *AppConfig) GetUserConfigDir() string {
return c.UserConfigDir
}
func (c *AppConfig) GetTempDir() string {
return c.TempDir
}
func (c *AppConfig) ReloadUserConfig() error {
userConfig, err := loadUserConfigWithDefaults(c.UserConfigDir)
if err != nil {