summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-02-26 19:53:00 +0100
committercashmere <cashmere@autistici.org>2026-02-26 19:53:00 +0100
commita81d9bb06eb4ca62747efbfe5d32c0f4e64fc792 (patch)
tree42fb8dafcc3af3b60b7b7009734a1391ce1ceb95
parent3c0d562a64590bee4d7aa5ee8226a0cd2717cacb (diff)
downloademacs-a81d9bb06eb4ca62747efbfe5d32c0f4e64fc792.tar.gz
add my/setup-git-remote: dual-push remote setup for dev.cashmere.rs + sr.ht
-rw-r--r--config.el19
-rw-r--r--config.org27
2 files changed, 46 insertions, 0 deletions
diff --git a/config.el b/config.el
index bf4162b..0217170 100644
--- a/config.el
+++ b/config.el
@@ -986,6 +986,25 @@ Copies the resulting URL to the kill ring and clipboard."
(interactive)
(my/snip-upload (read-file-name "Upload to snips.sh: ")))
+(defun my/setup-git-remote (dev-name srht-name)
+ "Set up origin (dual-push) and backup remotes for the current git repo.
+DEV-NAME is the repo name on dev.cashmere.rs, SRHT-NAME on sr.ht."
+ (interactive
+ (let* ((dev (read-string "Repo name (dev.cashmere.rs): "))
+ (srht (read-string (format "Repo name (sr.ht) [%s]: " dev) nil nil dev)))
+ (list dev srht)))
+ (let* ((root (or (locate-dominating-file default-directory ".git")
+ (error "Not in a git repository")))
+ (default-directory root)
+ (dev-url (format "ssh://git@dev.cashmere.rs/cashmere/%s" dev-name))
+ (srht-url (format "git@git.sr.ht:~cashmere/%s" srht-name)))
+ (shell-command (format "git remote remove origin 2>/dev/null; git remote add origin %s" dev-url))
+ (shell-command (format "git remote set-url --add --push origin %s" dev-url))
+ (shell-command (format "git remote set-url --add --push origin %s" srht-url))
+ (shell-command (format "git remote remove backup 2>/dev/null; git remote add backup %s" srht-url))
+ (message "Remotes configured:\n origin -> %s (push to both)\n backup -> %s"
+ dev-url srht-url)))
+
(defun my/paste-md-to-org ()
"Yank Markdown text as Org.
diff --git a/config.org b/config.org
index a9292d6..d2ad742 100644
--- a/config.org
+++ b/config.org
@@ -1171,6 +1171,33 @@ Copies the resulting URL to the kill ring and clipboard."
(my/snip-upload (read-file-name "Upload to snips.sh: ")))
#+end_src
+** my/setup-git-remote
+
+Set up dual-push git remotes for the current repository. Prompts for
+the repo name on dev.cashmere.rs and sr.ht, then configures origin to
+push to both servers. sr.ht auto-creates repos on first push.
+
+#+begin_src emacs-lisp
+(defun my/setup-git-remote (dev-name srht-name)
+ "Set up origin (dual-push) and backup remotes for the current git repo.
+DEV-NAME is the repo name on dev.cashmere.rs, SRHT-NAME on sr.ht."
+ (interactive
+ (let* ((dev (read-string "Repo name (dev.cashmere.rs): "))
+ (srht (read-string (format "Repo name (sr.ht) [%s]: " dev) nil nil dev)))
+ (list dev srht)))
+ (let* ((root (or (locate-dominating-file default-directory ".git")
+ (error "Not in a git repository")))
+ (default-directory root)
+ (dev-url (format "ssh://git@dev.cashmere.rs/cashmere/%s" dev-name))
+ (srht-url (format "git@git.sr.ht:~cashmere/%s" srht-name)))
+ (shell-command (format "git remote remove origin 2>/dev/null; git remote add origin %s" dev-url))
+ (shell-command (format "git remote set-url --add --push origin %s" dev-url))
+ (shell-command (format "git remote set-url --add --push origin %s" srht-url))
+ (shell-command (format "git remote remove backup 2>/dev/null; git remote add backup %s" srht-url))
+ (message "Remotes configured:\n origin -> %s (push to both)\n backup -> %s"
+ dev-url srht-url)))
+#+end_src
+
** my/paste-md-to-org
[[http://yummymelon.com/devnull/import-markdown-to-org-with-the-clipboard-in-emacs.html][nfdn: Import Markdown to Org with the Clipboard in Emacs]]