summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2021-09-27 22:39:20 +0900
committerJesse Duffield <jessedduffield@gmail.com>2021-09-29 22:05:58 +1000
commit663c036ca5c5639c772a3f37ccef50ff03979337 (patch)
treec300e7ea60e80148244deb7627de1410b339522a
parentc8e9d1b4fcde97dbdeae3463ef80da2c61fe5371 (diff)
Save patch files in TempDir
-rw-r--r--pkg/commands/files.go2
-rw-r--r--pkg/config/app_config.go9
2 files changed, 10 insertions, 1 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go
index 5ad6eeb66..74beb9fb7 100644
--- a/pkg/commands/files.go
+++ b/pkg/commands/files.go
@@ -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
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index b6d668439..6adfb9919 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -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 {