remove unused file
[iankelling.org] / gitweb-descriptions
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # my projects all have README or --help with a short single line
18 # description which I parse and put into the gitweb description.
19
20 # If it's a repo with just a single bash script or *-function script,
21 # then call it with --help, grap the 2nd line.
22 # else, parse the readme, find the first non blank, not starting with [#*],
23 # and use that line.
24
25 set -e; . /usr/local/lib/bash-bear; set +e
26
27 if [[ ! $1 ]]; then
28 echo "need gitroot arg"
29 exit 1
30 fi
31
32 gitroot=$1
33 cd $gitroot
34
35 shopt -s extglob
36 shopt -s nullglob
37
38 _git_desc_readme() {
39 x=(README*)
40 if [[ ! $x ]]; then
41 echo "$1: error: no README at $PWD"
42 exit 1
43 fi
44 while read -r line; do
45 [[ $line ]] || continue
46 if echo "$line" | grep "^ *[#*]" &>/dev/null; then
47 continue
48 fi
49 echo "$line" > .git/description
50 break
51 done < README*
52 }
53
54 gitweb-descriptions() {
55 for d in ${dirs[@]}; do
56 echo $d
57 cd $(readlink -f $d)/..
58 [[ -e .git ]] || echo $d
59 if [[ ${personalized[${d##*/}]} ]]; then
60 echo "$pcategory" >.git/category
61 fi
62 if [[ ${unmaintained[${d##*/}]} ]]; then
63 echo "$ucategory" >.git/category
64 fi
65 if [[ ${historicalarchive[${d##*/}]} ]]; then
66 echo "$hcategory" >.git/category
67 fi
68 f=(!(LICENSE|COPYING|README|.git))
69 if [[ ${#f[@]} == 1 && ! -d $f ]]; then
70 if [[ ! -x $f ]]; then
71 if [[ $f == *-function ]]; then
72 ${f%-function} --help | sed -n '2p' > .git/description
73 else
74 _git_desc_readme
75 fi
76 else
77 ./$f --help | sed -n '2p' > .git/description
78 fi
79 else
80 _git_desc_readme
81 fi
82 done
83 }
84
85 tmp=(
86 bashrc
87 automated-distro-installer
88 buildscripts
89 distro-setup
90 dot-emacs
91 fai-basefiles
92 ian-misc-bash
93 iankelling.org
94 keyboard.io-layout
95 )
96 declare -A personalized
97 for p in ${tmp[@]}; do personalized[$p]=true; done
98 pcategory="Personalized for my use. Useful as examples or to copy specific parts"
99
100 tmp=(
101 bbdb-csv-import
102 evhz
103 )
104 ucategory="I don't use these anymore, they may or may not work, patches welcome"
105 declare -A unmaintained
106 for p in ${tmp[@]}; do unmaintained[$p]=true; done
107
108 tmp=(
109 bash-template
110 debian-auto-update
111 fdroidcl-up
112 mediawiki-setup
113 mediawiki-librejs-patch
114 mediawiki-sidebar-patch
115 )
116 hcategory="Historical archive. They don't work or have been superseded."
117 declare -A historicalarchive
118 for p in ${tmp[@]}; do historicalarchive[$p]=true; done
119
120 dirs=()
121 for d in $gitroot/*; do
122 if [[ ! -L $d ]]; then
123 continue
124 fi
125 dirs+=($d)
126 done
127
128 gitweb-descriptions "$@"