Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
remote-helper: Change default push option 'sync' to 'no-sync'
Adrian Duke committed 2 months ago
commit 41416af2bc8bd0c2f7e9b67c46cc29e4f71478e0
parent 30701cc6fbfea03f7ac0e4b7f5af883592791abf
3 files changed +33 -17
modified CHANGELOG.md
@@ -20,6 +20,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
  to create temporary patches.
- The `rad id` command will provide a better error message when a non-delegate
  attempts to modify the identity document.
+
- `git-remote-helper` is now safer by default, the push option `no-sync` has 
+
  replaced the existing value of `sync`. Repositories do not sync with the
+
  network on push. You can restore the old behaviour in one of two ways:
+
  1. Use `-o sync` for each `git push` you wish to sync.
+
  2. Set the git config `push.pushOption` to `sync` with:
+
      ```
+
      $ git config --local push.pushOption "sync"
+
      ```

## Fixed Bugs

modified crates/radicle-remote-helper/src/main.rs
@@ -193,7 +193,7 @@ impl Branch {
#[derive(Debug, Default, Clone)]
struct Options {
    /// Don't sync after push.
-
    no_sync: bool,
+
    no_sync: Option<bool>,
    /// Sync debugging.
    sync_debug: bool,
    /// Enable hints.
@@ -404,9 +404,9 @@ fn run_loop<R: BufRead, W: Write, G: service::GitService, N: service::NodeSessio
fn push_option(args: &[&str], opts: &mut Options) -> Result<(), Error> {
    match args {
        ["hints"] => opts.hints = true,
-
        ["sync"] => opts.no_sync = false,
+
        ["sync"] => opts.no_sync = Some(false),
        ["sync.debug"] => opts.sync_debug = true,
-
        ["no-sync"] => opts.no_sync = true,
+
        ["no-sync"] => opts.no_sync = Some(true),
        ["patch.draft"] => opts.draft = true,
        ["patch.branch"] => opts.branch = Branch::MirrorUpstream,
        _ => {
modified crates/radicle-remote-helper/src/push.rs
@@ -455,21 +455,29 @@ pub(super) fn run(
            }
        }

-
        if !opts.no_sync {
-
            if profile.policies()?.is_seeding(&stored.id)? {
-
                // Connect to local node and announce refs to the network.
-
                // If our node is not running, we simply skip this step, as the
-
                // refs will be announced eventually, when the node restarts.
-
                if node.is_running() {
-
                    // Nb. allow this to fail. The push to local storage was still successful.
-
                    node.sync(stored, ok.into_values().flatten().collect(), opts, profile)
-
                        .ok();
-
                } else if hints {
-
                    hint("offline push, your node is not running");
-
                    hint("to sync with the network, run `rad node start`");
+
        match opts.no_sync {
+
            None => {
+
                hint("the sync default recently changed from 'sync' to 'no-sync'");
+
                hint("you can use `-o sync` with git push or set `git config --local push.pushOption \"sync\"` to restore the previous behaviour");
+
            }
+
            Some(no_sync) => {
+
                if !no_sync {
+
                    if profile.policies()?.is_seeding(&stored.id)? {
+
                        // Connect to local node and announce refs to the network.
+
                        // If our node is not running, we simply skip this step, as the
+
                        // refs will be announced eventually, when the node restarts.
+
                        if node.is_running() {
+
                            // Nb. allow this to fail. The push to local storage was still successful.
+
                            node.sync(stored, ok.into_values().flatten().collect(), opts, profile)
+
                                .ok();
+
                        } else if hints {
+
                            hint("offline push, your node is not running");
+
                            hint("to sync with the network, run `rad node start`");
+
                        }
+
                    } else if hints {
+
                        hint("you are not seeding this repository; skipping sync");
+
                    }
                }
-
            } else if hints {
-
                hint("you are not seeding this repository; skipping sync");
            }
        }
    }