aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/git
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-08-02 15:49:59 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-08-02 15:49:59 -0500
commit07f4d3045c491019d937773112d8d9494f324d08 (patch)
treeb9513ee47eae295003e770874369c5567e513c12 /git
parent66526d6f552037a6b3f9f6cce4de27e5ab35b567 (diff)
feat(git): add subcommand to export cgit repos
Diffstat (limited to 'git')
-rwxr-xr-xgit/.local/bin/git-export29
1 files changed, 29 insertions, 0 deletions
diff --git a/git/.local/bin/git-export b/git/.local/bin/git-export
new file mode 100755
index 0000000..7feabd0
--- /dev/null
+++ b/git/.local/bin/git-export
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+GIT_SERVER=${GIT_SERVER:-"git.tobyvin.dev"}
+
+help() {
+ cat <<-EOF
+ $(ssh "git@$GIT_SERVER" -- export --help | sed 's/<REPO> //g; /^\s\+REPO/d')
+
+ NOTE
+ The was run via the git-export helper script/shim. The current GIT_DIR,
+ is used as the <REPO> argument.
+ EOF
+}
+
+for arg; do
+ case "$arg" in
+ -h | --help)
+ help
+ exit 0
+ ;;
+ esac
+done
+
+if ! repo=$(git remote get-url origin | grep -Po "$GIT_SERVER:\K.*") || [ -z "$repo" ]; then
+ exit 1
+fi
+
+# shellcheck disable=SC2046
+ssh "git@$GIT_SERVER" -- export "$repo" $([ $# -gt 0 ] && printf '"%q" ' "$@")