diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-07-05 10:52:25 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-07-05 14:41:55 +0530 |
| commit | eca86870bf10c064a9f561249491f03c6e750a86 (patch) | |
| tree | 95676411d6f95babd1fdf5231c6fecc44f94cab9 /cgit/ssh/git-shell-commands | |
| parent | 2cd9a4039c0c5f524df0a33605c9baef1f57917e (diff) | |
| download | bacchus-remote-eca86870bf10c064a9f561249491f03c6e750a86.tar.gz bacchus-remote-eca86870bf10c064a9f561249491f03c6e750a86.zip | |
Add fork/set-description git commands + optimizations
Diffstat (limited to 'cgit/ssh/git-shell-commands')
| -rwxr-xr-x | cgit/ssh/git-shell-commands/fork | 32 | ||||
| -rwxr-xr-x | cgit/ssh/git-shell-commands/set-description | 25 |
2 files changed, 57 insertions, 0 deletions
diff --git a/cgit/ssh/git-shell-commands/fork b/cgit/ssh/git-shell-commands/fork new file mode 100755 index 0000000..52803d3 --- /dev/null +++ b/cgit/ssh/git-shell-commands/fork @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +set -eu + +remote_host="git.ediblemonad.dev" +owner_info="Akshay Nair <phenax5@gmail.com>" + +if [ $# -lt 2 ]; then + echo "Usage: fork <name> <url>" 1>&2 + exit 1 +fi + +repo_name="$1"; shift 1; +[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1 + +remote_repo_url="$1"; shift 1; +[ -z "$remote_repo_url" ] && echo "Error: empty repo url" 1>&2 && exit 1 + +repo_dir="/git/${repo_name}.git" + +if [ -d "$repo_dir" ]; then + echo "Error: $repo_name already exists" 1>&2 + exit 1; +fi + +git clone --bare "$remote_repo_url" "$repo_dir" + +cd "$repo_dir" +echo "Fork of $remote_repo_url" > description +echo "$owner_info" > owner_info + +echo "git@${remote_host}:${repo_dir}" diff --git a/cgit/ssh/git-shell-commands/set-description b/cgit/ssh/git-shell-commands/set-description new file mode 100755 index 0000000..a120fa0 --- /dev/null +++ b/cgit/ssh/git-shell-commands/set-description @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +set -eu + +if [ $# -lt 2 ]; then + echo "Usage: set-description <name> <...description>" 1>&2 + exit 1 +fi + +repo_name="$1"; shift 1; +[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1 + +description="$*"; +[ -z "$description" ] && echo "Error: empty description" 1>&2 && exit 1 + +repo_dir="/git/${repo_name}.git" + +if ! [ -d "$repo_dir" ]; then + echo "Error: $repo_name doesn't exist" 1>&2 + exit 1; +fi + +echo "$description" > "${repo_dir}/description" + +echo "Done" |
