original.yaml has just todo, merge against .original.yaml so mobile edits still get a history
parent
29bc6a06b4
commit
242ad3e127
|
|
@ -90,7 +90,9 @@ func (config config) targets() ([]string, error) {
|
|||
for i := range results {
|
||||
if stat, err := os.Stat(results[i]); err != nil {
|
||||
return nil, err
|
||||
} else if !stat.IsDir() {
|
||||
} else if stat.IsDir() {
|
||||
} else if strings.HasPrefix(path.Base(results[i]), ".") && isDir {
|
||||
} else {
|
||||
result = append(result, results[i])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
cmd/edit.go
13
cmd/edit.go
|
|
@ -61,6 +61,10 @@ func _edit(filepaths []string) error {
|
|||
original, err := pttodo.NewRootFromFile(func() string {
|
||||
for _, f := range filepaths {
|
||||
if path.Base(f) == path.Base(editedFile) {
|
||||
rootF := path.Join(path.Dir(f), "."+path.Base(f))
|
||||
if _, err := os.Stat(rootF); err == nil {
|
||||
f = rootF
|
||||
}
|
||||
return f
|
||||
}
|
||||
}
|
||||
|
|
@ -102,8 +106,15 @@ func _edit(filepaths []string) error {
|
|||
|
||||
dir := ""
|
||||
for _, f := range filepaths {
|
||||
rootF := path.Join(path.Dir(f), "."+path.Base(f))
|
||||
if edited, ok := edits[path.Base(f)]; ok {
|
||||
if err := rename(edited, f); err != nil {
|
||||
if todos, err := pttodo.NewRootFromFile(edited); err != nil {
|
||||
return err
|
||||
} else if b, err := yaml.Marshal(todos.Todo); err != nil {
|
||||
return err
|
||||
} else if err := rename(edited, rootF); err != nil {
|
||||
return err
|
||||
} else if err := os.WriteFile(f, b, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
delete(edits, path.Base(f))
|
||||
|
|
|
|||
Loading…
Reference in New Issue