From 0786150ef4d2d7550d417cc2764245171e1691a6 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Wed, 19 Feb 2025 13:41:20 +0300 Subject: [PATCH] added man entry for repo:init --- hbs2-git3/lib/HBS2/Git3/Repo/Init.hs | 4 --- hbs2-git3/lib/HBS2/Git3/Run.hs | 50 ++++++++++++++++++++++++++-- hbs2-git3/lib/HBS2/Git3/State.hs | 2 +- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/hbs2-git3/lib/HBS2/Git3/Repo/Init.hs b/hbs2-git3/lib/HBS2/Git3/Repo/Init.hs index abf26bad..d4caa9cc 100644 --- a/hbs2-git3/lib/HBS2/Git3/Repo/Init.hs +++ b/hbs2-git3/lib/HBS2/Git3/Repo/Init.hs @@ -10,7 +10,6 @@ import HBS2.Git3.Export import HBS2.System.Dir -import HBS2.CLI.Run.MetaData import HBS2.Net.Auth.Credentials import HBS2.Net.Auth.GroupKeySymm @@ -19,11 +18,8 @@ import HBS2.KeyMan.Keys.Direct import Data.Config.Suckless.Script import Data.Config.Suckless.Almost.RPC -import Data.ByteString.Lazy.Char8 qualified as LBS8 import Data.Word -import Data.Maybe import Data.Text qualified as Text -import Data.HashMap.Strict qualified as HM import Lens.Micro.Platform import System.Random hiding (next) diff --git a/hbs2-git3/lib/HBS2/Git3/Run.hs b/hbs2-git3/lib/HBS2/Git3/Run.hs index 157ca519..1225ff87 100644 --- a/hbs2-git3/lib/HBS2/Git3/Run.hs +++ b/hbs2-git3/lib/HBS2/Git3/Run.hs @@ -560,13 +560,57 @@ compression ; prints compression level liftIO $ for_ keys $ \k -> do liftIO $ print $ pretty k - entry $ bindMatch "repo:init" $ nil_ $ \syn -> lift $ connectedDo do - Repo.initRepo syn + + let initExamples = [qc| +; just init a new repository + +hbs2-git init --new + +; init encrypted repository + +; create new group key: +; your real keys will be different +; all hashes/keys appear in exampels/logs a PUBLIC information, +; so no secrets disclosures. + +hbs2-cli hbs2:groupkey:store [hbs2:groupkey:create 67CRxnoQWasQsY9iidjJDYXSTKEZkpSVgDQYweWuhfd3] +39baH7SqqsAGgCSr3k9RJgY4nTwiMRXrgZUmKPFndzn8 + + +hbs2-git init --new --encrypted 39baH7SqqsAGgCSr3k9RJgY4nTwiMRXrgZUmKPFndzn8 + +added git remote laundry-worry hbs23://7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx +updateRepoKey 7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx + +git remote + +laundry-worry +^^^^^^^^^^^^^ + +This is the git remote for the new repo. Rename it if you want. + +hbs2-git3 repo:remotes +7F1D7QGVVwJFJ649dsSHgrDUuqHYti3nkFx laundry-worry + + +|] + let initMan = brief "initializes a new repository" + . args [ arg "new repository flag" "--new" + , arg "group key hash for encrypted repository" "<--encrypted group-key>" + ] + . examples initExamples + + initMan $ + entry $ bindMatch "repo:init" $ nil_ $ \syn -> lift $ connectedDo do + Repo.initRepo syn + + initMan $ entry $ + bindAlias "init" "repo:init" entry $ bindMatch "repo:relay-only" $ nil_ $ \case [ SignPubKeyLike repo ] -> lift $ connectedDo do setGitRepoKey repo - waitRepo (Just 3) =<< getGitRepoKeyThrow + waitRepo (Just 10) =<< getGitRepoKeyThrow _ -> throwIO (BadFormException @C nil) diff --git a/hbs2-git3/lib/HBS2/Git3/State.hs b/hbs2-git3/lib/HBS2/Git3/State.hs index be829d67..32f22169 100644 --- a/hbs2-git3/lib/HBS2/Git3/State.hs +++ b/hbs2-git3/lib/HBS2/Git3/State.hs @@ -262,7 +262,7 @@ waitRepo timeout repoKey = do notice "wait for peer" - lift (callRpcWaitMay @RpcPollAdd (TimeoutSec 1) peerAPI (repoKey, "lwwref", 31)) + lift (callRpcWaitMay @RpcPollAdd (TimeoutSec 2) peerAPI (repoKey, "lwwref", 31)) >>= maybe (wait 1 forPeer ()) (const none) pFetch <- ContT $ withAsync $ forever do