summaryrefslogtreecommitdiff
path: root/examples/pkglist
blob: 7e6747f9757312c5b964b49a56259602bf15a432 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env zsh
## on the PKG_HOST: list available packages
## used by ct update remote
## the PKG_PATH (package root path) is given as first argument ($1)

if [[ -z $1 ]] {
	echo "Usage: $0 <package root path>" >&2
	exit 1
}

if [[ ! -d $1 ]] {
	echo "$0: package root directory '$1' does not exist!" >&2
	exit 1
}

setopt err_exit

cd $1
shift

for dir in *(-/); {

	# git repo
	if [[ -d $dir/.git ]] {
		echo -n "$dir git "
		echo -n ${$(git --git-dir=$dir/.git log -n 1)[2]}
		echo " $*"

	# bare git repo
	} elif [[ -d $dir/objects && -d $dir/refs ]] {
		echo -n "$dir git "
		echo -n ${$(git --git-dir=$dir log -n 1)[2]}
		echo " $*"

	# unknown
	} else {
		echo "$dir: Unsupported or no repository" >&2
	}
}