aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/git/.local/bin/git-export
blob: 7feabd05a391bef5ce024a16b26c005c41a70751 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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" ' "$@")