diff options
Diffstat (limited to 'cgit/ssh')
| -rwxr-xr-x | cgit/ssh/git-shell-commands/list | 15 | ||||
| -rwxr-xr-x | cgit/ssh/git-shell-commands/set-category | 28 |
2 files changed, 33 insertions, 10 deletions
diff --git a/cgit/ssh/git-shell-commands/list b/cgit/ssh/git-shell-commands/list index 804a488..8a924c9 100755 --- a/cgit/ssh/git-shell-commands/list +++ b/cgit/ssh/git-shell-commands/list @@ -1,13 +1,8 @@ #!/usr/bin/env sh -ls -1 /git | while IPS="" read name; do - echo "$name" - printf " description: " - if [ -f "/git/${name}/description" ]; then - cat "/git/${name}/description" - else - echo "<no description>" - fi - echo "" -done +git_dir=/git + +ls -1 "$git_dir" | while IPS="" read name; do + echo "$name||||$(cat "${git_dir}/${name}/description" 2>/dev/null)" +done | column -t -d -s "||||" diff --git a/cgit/ssh/git-shell-commands/set-category b/cgit/ssh/git-shell-commands/set-category new file mode 100755 index 0000000..7f74b94 --- /dev/null +++ b/cgit/ssh/git-shell-commands/set-category @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +set -eu + +if [ $# -lt 1 ]; then + echo "Usage: set-category <name> [category]" 1>&2 + exit 1 +fi + +repo_name="$1"; +[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1 +(echo "$repo_name" | grep -q "^[A-Za-z0-9_-]\+$" 2>/dev/null) || (echo "Error: invalid repo name" 1>&2 && exit 1) + +category="${2:-""}"; +repo_dir="/git/${repo_name}.git" + +if ! [ -d "$repo_dir" ]; then + echo "Error: $repo_name doesn't exist" 1>&2 + exit 1; +fi + +if [ -z "$category" ]; then + git -C "$repo_dir" config unset gitweb.category +else + git -C "$repo_dir" config set gitweb.category "$category" +fi + +echo "Done" |
