0.1.3: upload a vault to a team from the app, detach first; AGPL-3.0

- The Lune window shows Upload on a vault that isn't on a team, for the team
  owner and anyone who manages a vault there. The hub now lets those people
  create vaults too (was owner only); /api/me and the canvas say can_create.
- A vault on its own remote (GitHub, GitLab, Gitea…) must be detached first
  (`lunesync vault detach`, or the Upload sheet's Detach): it shares what's
  waiting one last time, then lives on this device only. Upload refuses
  anything else, and a check-in no longer silently moves a same-named vault
  off its own remote onto the hub.
- Upload logic moved from the CLI into core (lune_core::upload).
- Canvas: "1 person loses access".
- License: AGPL-3.0-only. README and SPEC §8 updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 16:44:36 +07:00
parent 584b279496
commit 4ab9d580b8
26 changed files with 1082 additions and 70 deletions

View File

@@ -279,6 +279,10 @@ impl Vault {
/// Points the vault at a new remote (e.g. moving onto the hub). Its next sync shares everything there.
pub fn relink(&self, url: &str) -> Result<()> {
if self.is_local() {
self.repo.remote("origin", url)?;
return Ok(());
}
self.repo.remote_set_url("origin", url)?;
if let Ok(mut r) = self.repo.find_reference(&self.remote_ref()) {
r.delete()?;
@@ -286,6 +290,19 @@ impl Vault {
Ok(())
}
/// A vault with no remote lives on this device only: it keeps saving history, and shares nowhere.
pub fn is_local(&self) -> bool {
self.repo.find_remote("origin").is_err()
}
/// Stops sharing with the remote; the notes and their history stay here.
pub fn unlink(&self) -> Result<()> {
if !self.is_local() {
self.repo.remote_delete("origin")?;
}
Ok(())
}
/// Starts history over with just the current notes (the old history stays only on this device).
/// Returns where history was, to go back if needed.
pub fn fresh_start(&self, message: &str) -> Result<Oid> {
@@ -405,6 +422,9 @@ impl Vault {
/// One sync round: fetch, combine, write the result to disk, share local history.
pub fn sync(&self) -> Result<SyncReport> {
let mut report = SyncReport::default();
if self.is_local() {
return Ok(report);
}
for _ in 0..3 {
self.fetch()?;
let local = self.head_commit()?;