A peer-to-peer stack for code collaboration
Make rad project work with existing git repos. (#507)
James Haydon6d79f5b15bb4
diff --git a/bin/rad-project b/bin/rad-projectindex bbc7ce4..d271a8c 100755--- a/bin/rad-project+++ b/bin/rad-project@@ -91,20 +91,30 @@(def setup-repo!(fn []+ (def current-remote (get-git-config! "remote.origin.url"))(def question(unlines- ["? What kind of repository would you like to use?"- "1. New peer-to-peer repository (git-ipfs **EXPERIMENTAL**)"- "2. Add your own remote (e.g.: github / gitlab / ...)"- " (see radicle.xyz/docs/storage for more info)\n"]))+ (concat+ [["? What kind of repository would you like to use?"+ "1. New peer-to-peer repository (git-ipfs **EXPERIMENTAL**)"+ "2. Add your own remote (e.g.: github / gitlab / ...)"]+ (match current-remote+ "" []+ 'url ["3. Remote origin of existing current git repository:"+ (string-append " " url)])+ ["(see radicle.xyz/docs/storage for more info)\n"]])))(match (prompt! question)"1" (init-git-ipfs-repo cid-of-empty-repo)- "2" (prompt! "Please input the remote git repo URL:")+ "2" (prompt! "Please input the remote git repo URL: ")+ "3" (if (eq? current-remote "")+ (do (put-str! "No current remote origin set; please select 1 or 2.")+ (exit! !))+ current-remote)_ (do (put-str! "You must select either 1 or 2.")(exit! 1)))))(def setup-upstream!- "Creates a commit to set the upstream to master, if master does not exist yet"+ "Creates a commit to set the upstream to master, if master does not exist yet."(fn [](match (process-with-stdout! "git" ["show-ref" "refs/heads/master"] "")[] (do@@ -116,21 +126,32 @@(error/upstream-push-failure)))_ :ok)))+(def detect-git!+ "Detect if the directory is already a git repository."+ (fn []+ (match (process! "test" ["-d" ".git"] "")+ :ok #t+ _ #f)))+(def new-project!"Create a new project."(fn [](def meta (prompt-for-metadata!))(def project (create-project! meta))- (process! "git" ["init"] "")+ (if (not (detect-git!))+ (process! "git" ["init"] "")+ :ok)(def repo (setup-repo!))(config-ipfs-api-url! repo)- (put-str! (string-append "=> adding \"origin\" remote: " repo))(def issues (create-issue-machine!))(put-str! "=> Assembled rad-issue machine")(def diff (create-diff-machine!))(put-str! "=> Assembled rad-diff machine")(put-str! (string-append "=> project id: " project))- (process! "git" ["remote" "add" "origin" repo] "")+ (if (eq? "" (get-git-config! "remote.origin.url"))+ (do (put-str! (string-append "=> adding \"origin\" remote: " repo))+ (process! "git" ["remote" "add" "origin" repo] ""))+ :ok)(setup-upstream!)(add-rsm! project { :id repo :type :rad-repo })(add-rsm! project { :id issues :type :rad-issue })diff --git a/docs/source/reference.rst b/docs/source/reference.rstindex f24a480..e61b8b4 100644--- a/docs/source/reference.rst+++ b/docs/source/reference.rst@@ -780,6 +780,11 @@ works for stringsMatches sequences that start with ``prefix`` and bind the rest of thatsequence to ``rest-pat``. Also works for strings.+``(concat ss)``+~~~~~~~~~~~~~~~++Concatenate a sequence of sequences.+``prelude/strings``-------------------diff --git a/rad/prelude/seq.rad b/rad/prelude/seq.radindex 03c8861..0435bfb 100644--- a/rad/prelude/seq.rad+++ b/rad/prelude/seq.rad@@ -1,7 +1,7 @@{:module 'prelude/seq:doc "Functions for manipulating sequences, that is lists and vectors.":exports '[empty? seq? reverse filter take-while starts-with? /prefix- ]}+ concat]}(import prelude/basic :unqualified)(import prelude/bool :unqualified)@@ -144,3 +144,14 @@)==> :fall-through ])++(def concat+ "Concatenate a sequence of sequences."+ (fn [ss] (foldl <> [] ss)))++(:test "concat"+ [ (concat []) ==> [] ]+ [ (concat [[]]) ==> [] ]+ [ (concat [[] []]) ==> [] ]+ [ (concat [[1 2] [3 4] [5]]) ==> [1 2 3 4 5]]+ [ (concat [[] [1 2] [] [3 4] [5] []]) ==> [1 2 3 4 5]])