Commit a42c6a2
committed
fix(cli): cleanup local DB state on set-cloud/set-local
Per maintainer direction (#680), `set-cloud` is now a one-way cutover
rather than a routing toggle. Before this change, `set-cloud` only
flipped `mode = cloud` in config and left the project's row in the
local index DB alone — so `_merge_projects` continued to see the
project on both sides and reported `source: "local+cloud"`, with the
old `local_path` still populated. Confusing state, no clean way out
without manually editing both `config.json` and `memory.db`.
Changes:
- `set-cloud` now drops the project's row from the local index DB
and clears `path` in config. On-disk note files are preserved —
the user can keep, archive, or delete them as they like.
- `set-local` is the symmetric inverse. It accepts `--local-path` and
recreates the local DB row at the resolved path. If the prior path
is still in config (e.g. set-local on a project that was already
local), `--local-path` may be omitted and the existing path is reused.
- Both helpers (`_detach_local_project_row`, `_attach_local_project_row`)
are idempotent: running set-cloud twice doesn't error; running
set-local twice updates the path if it changed and otherwise no-ops.
Tests:
- `test_set_cloud_clears_path` — config `path` blanked after set-cloud
- `test_set_local_requires_path_after_set_cloud` — regression for the
exact loop the reporter described: re-binding to local must not
silently default
- `test_set_local_success` — full round trip with an explicit path
Closes #680
Signed-off-by: phernandez <paul@basicmachines.co>1 parent 128c2da commit a42c6a2
2 files changed
Lines changed: 161 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
841 | 907 | | |
842 | 908 | | |
843 | 909 | | |
| |||
855 | 921 | | |
856 | 922 | | |
857 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
858 | 931 | | |
859 | 932 | | |
860 | 933 | | |
| |||
883 | 956 | | |
884 | 957 | | |
885 | 958 | | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
886 | 965 | | |
887 | 966 | | |
888 | 967 | | |
| 968 | + | |
| 969 | + | |
889 | 970 | | |
890 | 971 | | |
891 | 972 | | |
892 | 973 | | |
893 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
894 | 979 | | |
895 | 980 | | |
896 | 981 | | |
897 | 982 | | |
898 | 983 | | |
899 | 984 | | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
900 | 993 | | |
901 | 994 | | |
902 | 995 | | |
903 | | - | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
904 | 1001 | | |
905 | | - | |
906 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
907 | 1005 | | |
908 | 1006 | | |
909 | 1007 | | |
| |||
913 | 1011 | | |
914 | 1012 | | |
915 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
916 | 1032 | | |
917 | 1033 | | |
| 1034 | + | |
918 | 1035 | | |
919 | 1036 | | |
920 | 1037 | | |
| 1038 | + | |
921 | 1039 | | |
922 | 1040 | | |
923 | 1041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | | - | |
| 172 | + | |
170 | 173 | | |
171 | 174 | | |
| 175 | + | |
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
| |||
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
180 | | - | |
| 184 | + | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
185 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
186 | 201 | | |
187 | 202 | | |
188 | 203 | | |
| |||
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
201 | | - | |
202 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
203 | 222 | | |
204 | 223 | | |
205 | 224 | | |
| |||
211 | 230 | | |
212 | 231 | | |
213 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
214 | 245 | | |
215 | 246 | | |
216 | 247 | | |
| |||
0 commit comments