aboutsummaryrefslogtreecommitdiff
path: root/nix/per-host/git/git-shell-commands/desc
blob: cd0e569abddc015eb06b6d7a7751eecc3c601c1e (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
#!/usr/bin/env bash
# git-shell-commands(5) subcommand: set or show a repo's description as
# displayed in cgit.
# Run: ssh git@git.kumardamani.net desc <name> [description...]

name="${1:-}"
case "$name" in
  ""|*[!a-zA-Z0-9._-]*|*..*)
    echo "usage: desc <name> [description...]" >&2
    exit 1
    ;;
esac
repo="/srv/git/$name.git"
if [ ! -d "$repo" ]; then
  echo "error: no such repo '$name'" >&2
  exit 1
fi
shift
if [ $# -eq 0 ]; then
  cat "$repo/description"
  exit 0
fi
printf '%s\n' "$*" > "$repo/description"
echo "description for '$name':"
cat "$repo/description"