mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 07:16:11 +00:00
chore: rename project to grove and add MIT license
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
126acb4b57
commit
c935d779e1
29 files changed
+99
-76
No files matched your search
@@ -1,10 +1,10 @@
|
||||
# Grove (working name: gitsync)
|
||||
# Grove
|
||||
|
||||
## Overview
|
||||
Linux tool that keeps chosen git repos continuously in sync across machines, including
|
||||
uncommitted work, via snapshot refs (`refs/sync/<machine>/<branch>`) on a primary remote.
|
||||
Planned as a Rust workspace (core, providers, daemon, CLI, Tauri GUI). Currently in
|
||||
**Phase 0 done, Phase 1 implemented (pending real two-PC validation and review)**: `gitsync-core` + `gitsync` CLI (`status`, `snapshot`, `add`, `sync`, `doctor`); daemon, GUI and providers do not exist yet. Do not start a
|
||||
**Phase 0 done, Phase 1 implemented (pending real two-PC validation and review)**: `grove-core` + `grove` CLI (`status`, `snapshot`, `add`, `sync`, `doctor`); daemon, GUI and providers do not exist yet. Do not start a
|
||||
new phase before its predecessor's results are written to `docs/`.
|
||||
|
||||
## Commands
|
||||
|
||||
Generated
+3
-3
@@ -111,16 +111,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "gitsync"
|
||||
name = "grove"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"gitsync-core",
|
||||
"grove-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitsync-core"
|
||||
name = "grove-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
members = ["crates/gitsync-core", "crates/gitsync"]
|
||||
members = ["crates/grove-core", "crates/grove"]
|
||||
|
||||
[workspace.package]
|
||||
edition = "2024"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
license = "MIT"
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Darío
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,4 +1,8 @@
|
||||
# Grove
|
||||
|
||||
Keeps your git repos in sync across machines without manual commit/push/pull, including
|
||||
work in progress. Early stage (spikes only). See `docs/` for details.
|
||||
work in progress. Early stage (Phase 1: core library and CLI). See `docs/` for details.
|
||||
|
||||
## License
|
||||
|
||||
MIT, see `LICENSE`.
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gitsync-core"
|
||||
description = "Sync engine for gitsync: snapshots, state classification"
|
||||
name = "grove-core"
|
||||
description = "Sync engine for grove: snapshots, state classification"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
@@ -130,20 +130,20 @@ impl Config {
|
||||
Config::parse(&text)
|
||||
}
|
||||
|
||||
/// Default location: `$XDG_CONFIG_HOME/gitsync/config.toml` or `~/.config/...`.
|
||||
/// Default location: `$XDG_CONFIG_HOME/grove/config.toml` or `~/.config/...`.
|
||||
pub fn default_path() -> Option<PathBuf> {
|
||||
let base = std::env::var_os("XDG_CONFIG_HOME")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".config")))?;
|
||||
Some(base.join("gitsync/config.toml"))
|
||||
Some(base.join("grove/config.toml"))
|
||||
}
|
||||
|
||||
/// Local state directory: `$XDG_STATE_HOME/gitsync` or `~/.local/state/gitsync`.
|
||||
/// Local state directory: `$XDG_STATE_HOME/grove` or `~/.local/state/grove`.
|
||||
pub fn state_dir() -> Option<PathBuf> {
|
||||
let base = std::env::var_os("XDG_STATE_HOME")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".local/state")))?;
|
||||
Some(base.join("gitsync"))
|
||||
Some(base.join("grove"))
|
||||
}
|
||||
|
||||
/// `root.path` with a leading `~` expanded.
|
||||
@@ -224,7 +224,7 @@ mirror_to = ["github"]
|
||||
fetch_interval_s = 30
|
||||
[config_repo]
|
||||
provider = "gitea-main"
|
||||
name = "gitsync-config"
|
||||
name = "grove-config"
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
File renamed without changes.
File renamed without changes.
@@ -70,7 +70,7 @@ mod tests {
|
||||
fn invariants_hold_for_random_names() {
|
||||
let alphabet: Vec<char> = "ab/._- é\\:*?\"<>|0Z".chars().collect();
|
||||
let mut seed = 0x1234_5678_u64;
|
||||
let mut taken: Vec<String> = vec![".bare".into(), ".gitsync-stage".into()];
|
||||
let mut taken: Vec<String> = vec![".bare".into(), ".grove-stage".into()];
|
||||
for _ in 0..2000 {
|
||||
let len = {
|
||||
seed = seed
|
||||
File renamed without changes.
@@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
const BARE: &str = ".bare";
|
||||
const STAGE: &str = ".gitsync-stage";
|
||||
const STAGE: &str = ".grove-stage";
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum MigrateError {
|
||||
File renamed without changes.
@@ -36,7 +36,7 @@ fn temp_index_path() -> PathBuf {
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|d| d.as_nanos())
|
||||
.unwrap_or(0);
|
||||
std::env::temp_dir().join(format!("gitsync-index-{}-{nanos}", std::process::id()))
|
||||
std::env::temp_dir().join(format!("grove-index-{}-{nanos}", std::process::id()))
|
||||
}
|
||||
|
||||
/// Take a snapshot of `worktree` for `machine`. `message_stamp` is embedded in the
|
||||
@@ -58,10 +58,10 @@ pub fn take(worktree: &Path, machine: &str, message_stamp: &str) -> Result<Outco
|
||||
let snap = git
|
||||
.clone()
|
||||
.with_env("GIT_INDEX_FILE", tmp.0.to_string_lossy())
|
||||
.with_env("GIT_AUTHOR_NAME", "gitsync")
|
||||
.with_env("GIT_AUTHOR_EMAIL", "gitsync@localhost")
|
||||
.with_env("GIT_COMMITTER_NAME", "gitsync")
|
||||
.with_env("GIT_COMMITTER_EMAIL", "gitsync@localhost");
|
||||
.with_env("GIT_AUTHOR_NAME", "grove")
|
||||
.with_env("GIT_AUTHOR_EMAIL", "grove@localhost")
|
||||
.with_env("GIT_COMMITTER_NAME", "grove")
|
||||
.with_env("GIT_COMMITTER_EMAIL", "grove@localhost");
|
||||
|
||||
snap.run(&["add", "-A"])?;
|
||||
let tree = snap.run(&["write-tree"])?;
|
||||
@@ -75,7 +75,7 @@ pub fn take(worktree: &Path, machine: &str, message_stamp: &str) -> Result<Outco
|
||||
}
|
||||
|
||||
let head = snap.probe(&["rev-parse", "-q", "--verify", "HEAD"])?;
|
||||
let message = format!("gitsync snapshot {machine} {message_stamp}");
|
||||
let message = format!("grove snapshot {machine} {message_stamp}");
|
||||
let mut args: Vec<&str> = vec!["commit-tree", &tree];
|
||||
if let Some(h) = &head {
|
||||
args.extend(["-p", h]);
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,11 +1,11 @@
|
||||
#![allow(dead_code)]
|
||||
use gitsync_core::git::Git;
|
||||
use grove_core::git::Git;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub fn tmpdir(tag: &str) -> PathBuf {
|
||||
let p = std::env::temp_dir().join(format!(
|
||||
"gitsync-test-{tag}-{}-{}",
|
||||
"grove-test-{tag}-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -1,12 +1,12 @@
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::inspect::{state, worktrees};
|
||||
use gitsync_core::state::State;
|
||||
use grove_core::git::Git;
|
||||
use grove_core::inspect::{state, worktrees};
|
||||
use grove_core::state::State;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn tmpdir(tag: &str) -> PathBuf {
|
||||
let p = std::env::temp_dir().join(format!(
|
||||
"gitsync-test-{tag}-{}-{}",
|
||||
"grove-test-{tag}-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -1,7 +1,7 @@
|
||||
mod common;
|
||||
use common::*;
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::migrate::{MigrateError, Step, migrate, migrate_failing_after};
|
||||
use grove_core::git::Git;
|
||||
use grove_core::migrate::{MigrateError, Step, migrate, migrate_failing_after};
|
||||
use std::fs;
|
||||
|
||||
fn names(dir: &std::path::Path) -> Vec<String> {
|
||||
@@ -136,7 +136,7 @@ fn every_failure_point_rolls_back_to_the_original_layout() {
|
||||
}
|
||||
}
|
||||
|
||||
fn refused(r: Result<gitsync_core::migrate::Report, MigrateError>) -> String {
|
||||
fn refused(r: Result<grove_core::migrate::Report, MigrateError>) -> String {
|
||||
match r {
|
||||
Err(MigrateError::Refused(m)) => m,
|
||||
other => panic!("expected Refused, got {other:?}"),
|
||||
@@ -1,10 +1,10 @@
|
||||
mod common;
|
||||
use common::*;
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::migrate::migrate;
|
||||
use gitsync_core::receive::*;
|
||||
use gitsync_core::snapshot::take;
|
||||
use gitsync_core::state::State;
|
||||
use grove_core::git::Git;
|
||||
use grove_core::migrate::migrate;
|
||||
use grove_core::receive::*;
|
||||
use grove_core::snapshot::take;
|
||||
use grove_core::state::State;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -277,7 +277,7 @@ fn gone_branch_with_local_changes_is_kept_and_flagged() {
|
||||
}
|
||||
|
||||
fn state_of(p: &std::path::Path) -> State {
|
||||
gitsync_core::inspect::state(p)
|
||||
grove_core::inspect::state(p)
|
||||
}
|
||||
|
||||
// ---- regression tests for the review findings ----
|
||||
@@ -372,7 +372,7 @@ fn snapshot_apply_declines_instead_of_overwriting_local_ignored_file() {
|
||||
|
||||
#[test]
|
||||
fn archive_and_receive_in_one_pass_do_not_collide_on_backup_refs() {
|
||||
use gitsync_core::sync::{Options, sync_repo};
|
||||
use grove_core::sync::{Options, sync_repo};
|
||||
let w = world();
|
||||
migrate(&w.d2, "m2", &w.base.join("bk"), "1").unwrap();
|
||||
let root = w.d2.canonicalize().unwrap();
|
||||
@@ -1,11 +1,11 @@
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::snapshot::{Outcome, take};
|
||||
use grove_core::git::Git;
|
||||
use grove_core::snapshot::{Outcome, take};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn tmpdir(tag: &str) -> PathBuf {
|
||||
let p = std::env::temp_dir().join(format!(
|
||||
"gitsync-test-{tag}-{}-{}",
|
||||
"grove-test-{tag}-{}-{}",
|
||||
std::process::id(),
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
@@ -1,9 +1,9 @@
|
||||
mod common;
|
||||
use common::*;
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::receive::Applied;
|
||||
use gitsync_core::state::State;
|
||||
use gitsync_core::sync::{Options, sync_repo};
|
||||
use grove_core::git::Git;
|
||||
use grove_core::receive::Applied;
|
||||
use grove_core::state::State;
|
||||
use grove_core::sync::{Options, sync_repo};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[package]
|
||||
name = "gitsync"
|
||||
description = "gitsync command line client"
|
||||
name = "grove"
|
||||
description = "grove command line client"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.104"
|
||||
clap = { version = "4.6.7", features = ["derive"] }
|
||||
gitsync-core = { version = "0.1.0", path = "../gitsync-core" }
|
||||
grove-core = { version = "0.1.0", path = "../grove-core" }
|
||||
@@ -1,22 +1,19 @@
|
||||
use anyhow::{Context, Result, bail};
|
||||
use clap::{Parser, Subcommand};
|
||||
use gitsync_core::config::Config;
|
||||
use gitsync_core::git::Git;
|
||||
use gitsync_core::inspect::{state, worktrees};
|
||||
use gitsync_core::migrate::migrate;
|
||||
use gitsync_core::receive::{Applied, Archived, Received};
|
||||
use gitsync_core::snapshot::{Outcome, take};
|
||||
use gitsync_core::sync::{Options, SyncReport, git_dir_for, sync_repo};
|
||||
use grove_core::config::Config;
|
||||
use grove_core::git::Git;
|
||||
use grove_core::inspect::{state, worktrees};
|
||||
use grove_core::migrate::migrate;
|
||||
use grove_core::receive::{Applied, Archived, Received};
|
||||
use grove_core::snapshot::{Outcome, take};
|
||||
use grove_core::sync::{Options, SyncReport, git_dir_for, sync_repo};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
name = "gitsync",
|
||||
about = "Keep git workspaces in sync across machines"
|
||||
)]
|
||||
#[command(name = "grove", about = "Keep git workspaces in sync across machines")]
|
||||
struct Cli {
|
||||
/// Path to config.toml (default: $XDG_CONFIG_HOME/gitsync/config.toml)
|
||||
/// Path to config.toml (default: $XDG_CONFIG_HOME/grove/config.toml)
|
||||
#[arg(long, global = true)]
|
||||
config: Option<PathBuf>,
|
||||
#[command(subcommand)]
|
||||
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
|
||||
fn tmp(tag: &str) -> PathBuf {
|
||||
let p = std::env::temp_dir().join(format!("gitsync-cli-{tag}-{}", std::process::id()));
|
||||
let p = std::env::temp_dir().join(format!("grove-cli-{tag}-{}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&p);
|
||||
fs::create_dir_all(&p).unwrap();
|
||||
p
|
||||
@@ -24,7 +24,7 @@ fn git(dir: &Path, args: &[&str]) -> String {
|
||||
}
|
||||
|
||||
fn gs(cfg: &Path, dir: &Path, args: &[&str]) -> Output {
|
||||
Command::new(env!("CARGO_BIN_EXE_gitsync"))
|
||||
Command::new(env!("CARGO_BIN_EXE_grove"))
|
||||
.current_dir(dir)
|
||||
.arg("--config")
|
||||
.arg(cfg)
|
||||
+2
-1
@@ -3,4 +3,5 @@
|
||||
1. Custom refs on Gitea/Forgejo: supported on Forgejo 11, no fallback needed (see `phase0-spike.md`). Also confirmed on git.zenvairo.es (Gitea 1.25.4); mirror exclusion still to verify there.
|
||||
2. Snapshots are auto-applied only when the target worktree is clean, has no unpushed commits and HEAD can fast-forward to the snapshot's base; otherwise declined and reported (implemented in `receive::apply_snapshot`).
|
||||
3. Config: TOML for user intent (implemented); runtime state storage still open.
|
||||
4-5. Open.
|
||||
4. License: MIT (decided).
|
||||
5. Final name: Grove (decided; binary `grove`, crates `grove-core` and `grove`).
|
||||
+8
-8
@@ -1,18 +1,18 @@
|
||||
# Phase 1: core + CLI
|
||||
|
||||
Crates: `gitsync-core` (library) and `gitsync` (CLI). Everything shells out to the system `git`.
|
||||
Crates: `grove-core` (library) and `grove` (CLI). Everything shells out to the system `git`.
|
||||
|
||||
## CLI
|
||||
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `gitsync status [path]` | State of every worktree (`Synced`, `Dirty`, `Ahead`, `Behind`, `BehindDirty`, `Diverged`, `Error`) |
|
||||
| `gitsync snapshot [path]` | Snapshot the worktree into `refs/sync/<machine>/<branch>` (local only) |
|
||||
| `gitsync add <path>` | Migrate a plain clone to `.bare/` + one worktree per branch, in place |
|
||||
| `gitsync sync [path] [--offline]` | One full pass (below) |
|
||||
| `gitsync doctor` | Checks git, config, root, repo remotes and refspecs, inotify limit |
|
||||
| `grove status [path]` | State of every worktree (`Synced`, `Dirty`, `Ahead`, `Behind`, `BehindDirty`, `Diverged`, `Error`) |
|
||||
| `grove snapshot [path]` | Snapshot the worktree into `refs/sync/<machine>/<branch>` (local only) |
|
||||
| `grove add <path>` | Migrate a plain clone to `.bare/` + one worktree per branch, in place |
|
||||
| `grove sync [path] [--offline]` | One full pass (below) |
|
||||
| `grove doctor` | Checks git, config, root, repo remotes and refspecs, inotify limit |
|
||||
|
||||
Config: `~/.config/gitsync/config.toml` (or `--config`). Machine names are embedded in ref names, so
|
||||
Config: `~/.config/grove/config.toml` (or `--config`). Machine names are embedded in ref names, so
|
||||
they may only contain letters, digits, `-` and `_`.
|
||||
|
||||
## Sync pass (`sync_repo`)
|
||||
@@ -50,7 +50,7 @@ they may only contain letters, digits, `-` and `_`.
|
||||
## Known limitations
|
||||
|
||||
- Nested untracked git repos are snapshotted only as gitlinks (their content is not synced).
|
||||
- No crash-resume: a hard kill in the middle of `add` leaves `.gitsync-stage`; the error says where
|
||||
- No crash-resume: a hard kill in the middle of `add` leaves `.grove-stage`; the error says where
|
||||
the files are, but recovery is manual (the backup tar and ref exist).
|
||||
- Machine-name uniqueness across machines is not enforced.
|
||||
- Split-index repos are untested.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Start a throwaway Forgejo (dev only) on localhost:3300 with an admin user.
|
||||
set -euo pipefail
|
||||
podman rm -f gitsync-forgejo >/dev/null 2>&1 || true
|
||||
podman run -d --name gitsync-forgejo -p 3300:3000 \
|
||||
podman rm -f grove-forgejo >/dev/null 2>&1 || true
|
||||
podman run -d --name grove-forgejo -p 3300:3000 \
|
||||
-e FORGEJO__security__INSTALL_LOCK=true \
|
||||
-e FORGEJO__server__ROOT_URL=http://localhost:3300/ \
|
||||
-e FORGEJO__server__DISABLE_SSH=true \
|
||||
@@ -10,5 +10,5 @@ podman run -d --name gitsync-forgejo -p 3300:3000 \
|
||||
-e FORGEJO__mirror__ENABLED=true -e FORGEJO__migrations__ALLOW_LOCALNETWORKS=true -e FORGEJO__migrations__ALLOWED_DOMAINS=localhost \
|
||||
codeberg.org/forgejo/forgejo:11 >/dev/null
|
||||
for i in $(seq 60); do curl -fs localhost:3300/api/healthz >/dev/null && break; sleep 1; done
|
||||
podman exec --user git gitsync-forgejo forgejo admin user create --admin \
|
||||
podman exec --user git grove-forgejo forgejo admin user create --admin \
|
||||
--username spike --password spike-pass-123 --email spike@example.invalid --must-change-password=false
|
||||
+1
-1
@@ -16,6 +16,6 @@ tree=$(git write-tree)
|
||||
prev=$(git rev-parse -q --verify "$ref" || true)
|
||||
if [ -n "$prev" ] && [ "$(git rev-parse "$prev^{tree}")" = "$tree" ]; then echo "unchanged $prev"; exit 0; fi
|
||||
parents=(-p HEAD); [ -n "$prev" ] && parents+=(-p "$prev")
|
||||
commit=$(git commit-tree "$tree" "${parents[@]}" -m "gitsync snapshot $machine $(date -u +%FT%TZ)")
|
||||
commit=$(git commit-tree "$tree" "${parents[@]}" -m "grove snapshot $machine $(date -u +%FT%TZ)")
|
||||
git update-ref "$ref" "$commit"
|
||||
echo "$commit"
|
||||
Reference in new issue
Block a user