e (1953B) - raw
1 #!/bin/sh 2 # edit metadata of a repository 3 4 # check number of params 5 [ $# -ne 1 ] && echo "Usage: e repo[.git]" && exit 1 6 7 # set the repository name, adding .git if necessary 8 p=$(echo "$1" | sed 's/\.git$\|$/.git/i') 9 10 [ ! -d "$p" ] && echo "$p not found." && exit 1 11 12 get_category() { 13 if [ ! -f "$p/git-daemon-export-ok" ]; then 14 echo "Private repository" 15 elif [ ! -f "$p/category" ]; then 16 echo "Unlisted repository (public cloning but not listed on website)" 17 else 18 printf "Public repository, category: " 19 cat "$p/category" 20 fi 21 } 22 23 modify_metadata() { 24 printf "Enter new $1: " 25 read answer 26 echo "$answer" > "$p/$1" 27 } 28 29 modify_category() { 30 echo "Category options: 31 32 [p]rivate repository 33 [u]nlisted repository (public cloning but not listed on website) 34 35 [pr]ojects (public repository) 36 [pe]rsonal setup (public repository) 37 [m]iscellanea (public repository)" 38 39 printf ">>> " 40 read answer 41 42 case $answer in 43 p) rm -f "$p/git-daemon-export-ok"; rm -f "$p/category" ;; 44 u) touch "$p/git-daemon-export-ok"; rm -f "$p/category" ;; 45 pr) touch "$p/git-daemon-export-ok"; echo "Projects" > "$p/category" ;; 46 pe) touch "$p/git-daemon-export-ok"; echo "Personal setup" > "$p/category" ;; 47 m) touch "$p/git-daemon-export-ok"; echo "Miscellanea" > "$p/category" ;; 48 *) echo "Option unknown" ;; 49 esac 50 } 51 52 while true; do 53 echo "Editing repository $p. What data do you want to modify? 54 55 [u]rl: $(cat "$p/url") 56 [o]wner: $(cat "$p/owner") 57 [d]escription: $(cat "$p/description") 58 [c]ategory/visibility: $(get_category) 59 60 [e]xit" 61 62 printf "> " 63 read answer 64 65 case $answer in 66 u) modify_metadata "url" ;; 67 o) modify_metadata "owner" ;; 68 d) modify_metadata "description" ;; 69 c) modify_category ;; 70 e) break ;; 71 *) echo "Option unknown" ;; 72 esac 73 done 74 75 $HOME/git-shell-commands/r