mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-20 03:47:54 +02:00
Revert 2ca6c751d066f296bdf04598ee446005c572bdbe and instead have BackupAndRestore keep files on the same mount point
This commit is contained in:
parent
2ca6c751d0
commit
9b06e6980a
@ -47,11 +47,8 @@ func getInitialWd() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ResetLocalState(t *testing.T) {
|
func ResetLocalState(t *testing.T) {
|
||||||
homedir, err := os.UserHomeDir()
|
|
||||||
Check(t, err)
|
|
||||||
persistLog()
|
persistLog()
|
||||||
_ = BackupAndRestoreWithId(t, "-reset-local-state")
|
_ = BackupAndRestoreWithId(t, "-reset-local-state")
|
||||||
_ = os.RemoveAll(path.Join(homedir, data.GetHishtoryPath()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BackupAndRestore(t testing.TB) func() {
|
func BackupAndRestore(t testing.TB) func() {
|
||||||
@ -81,17 +78,11 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
|
|||||||
path.Join(homedir, data.GetHishtoryPath(), "config.sh"),
|
path.Join(homedir, data.GetHishtoryPath(), "config.sh"),
|
||||||
path.Join(homedir, data.GetHishtoryPath(), "config.zsh"),
|
path.Join(homedir, data.GetHishtoryPath(), "config.zsh"),
|
||||||
path.Join(homedir, data.GetHishtoryPath(), "config.fish"),
|
path.Join(homedir, data.GetHishtoryPath(), "config.fish"),
|
||||||
|
path.Join(homedir, data.GetHishtoryPath(), "hishtory"),
|
||||||
path.Join(homedir, ".bash_history"),
|
path.Join(homedir, ".bash_history"),
|
||||||
path.Join(homedir, ".zsh_history"),
|
path.Join(homedir, ".zsh_history"),
|
||||||
path.Join(homedir, ".local/share/fish/fish_history"),
|
path.Join(homedir, ".local/share/fish/fish_history"),
|
||||||
}
|
}
|
||||||
hishtoryBinaryPath := path.Join(homedir, data.GetHishtoryPath(), "hishtory")
|
|
||||||
if IsGithubAction() {
|
|
||||||
// On github actions, avoid constantly copying the binary back and forth since we aren't worried about an existing hishtory installation
|
|
||||||
_ = os.Remove(hishtoryBinaryPath)
|
|
||||||
} else {
|
|
||||||
renameFiles = append(renameFiles, hishtoryBinaryPath)
|
|
||||||
}
|
|
||||||
for _, file := range renameFiles {
|
for _, file := range renameFiles {
|
||||||
touchFile(file)
|
touchFile(file)
|
||||||
Check(t, rename(file, getBackPath(file, id)))
|
Check(t, rename(file, getBackPath(file, id)))
|
||||||
@ -116,7 +107,11 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
|
|||||||
t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err)
|
t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err)
|
||||||
}
|
}
|
||||||
persistLog()
|
persistLog()
|
||||||
Check(t, os.RemoveAll(path.Join(homedir, data.GetHishtoryPath())))
|
for _, file := range renameFiles {
|
||||||
|
if strings.Contains(file, data.GetHishtoryPath()) {
|
||||||
|
_ = os.Remove(file)
|
||||||
|
}
|
||||||
|
}
|
||||||
Check(t, os.MkdirAll(path.Join(homedir, data.GetHishtoryPath()), os.ModePerm))
|
Check(t, os.MkdirAll(path.Join(homedir, data.GetHishtoryPath()), os.ModePerm))
|
||||||
for _, file := range renameFiles {
|
for _, file := range renameFiles {
|
||||||
checkError(rename(getBackPath(file, id), file))
|
checkError(rename(getBackPath(file, id), file))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user