e (1820B) - 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 [a]rchived (public repository)" 37 38 printf ">>> " 39 read answer 40 41 case $answer in 42 p) rm -f "$p/git-daemon-export-ok"; rm -f "$p/category" ;; 43 u) touch "$p/git-daemon-export-ok"; rm -f "$p/category" ;; 44 pr) touch "$p/git-daemon-export-ok"; echo "Projects" > "$p/category" ;; 45 a) touch "$p/git-daemon-export-ok"; echo "Archived" > "$p/category" ;; 46 *) echo "Option unknown" ;; 47 esac 48 } 49 50 while true; do 51 echo "Editing repository $p. What data do you want to modify? 52 53 [u]rl: $(cat "$p/url") 54 [o]wner: $(cat "$p/owner") 55 [d]escription: $(cat "$p/description") 56 [c]ategory/visibility: $(get_category) 57 58 [e]xit" 59 60 printf "> " 61 read answer 62 63 case $answer in 64 u) modify_metadata "url" ;; 65 o) modify_metadata "owner" ;; 66 d) modify_metadata "description" ;; 67 c) modify_category ;; 68 e) break ;; 69 *) echo "Option unknown" ;; 70 esac 71 done 72 73 $HOME/git-shell-commands/r