mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-16 18:41:03 +01:00
Revert 2ca6c751d0
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) {
|
||||
homedir, err := os.UserHomeDir()
|
||||
Check(t, err)
|
||||
persistLog()
|
||||
_ = BackupAndRestoreWithId(t, "-reset-local-state")
|
||||
_ = os.RemoveAll(path.Join(homedir, data.GetHishtoryPath()))
|
||||
}
|
||||
|
||||
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.zsh"),
|
||||
path.Join(homedir, data.GetHishtoryPath(), "config.fish"),
|
||||
path.Join(homedir, data.GetHishtoryPath(), "hishtory"),
|
||||
path.Join(homedir, ".bash_history"),
|
||||
path.Join(homedir, ".zsh_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 {
|
||||
touchFile(file)
|
||||
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)
|
||||
}
|
||||
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))
|
||||
for _, file := range renameFiles {
|
||||
checkError(rename(getBackPath(file, id), file))
|
||||
|
Loading…
Reference in New Issue
Block a user