Summary Files Commits Branches @commit @diff @stats
path: root / scripts / private
blob: 7035c190f8abe5e6f9164d234cff0dfa8d2eed94 (plain) (blame)
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
#!/bin/bash

if [ -z "$1" ]
then
	printf 'Repository: '
	read
	set "$REPLY"
fi

if [ ! -f "$1/HEAD" ]
then
	echo 'Repository has been deleted or moved!'
fi

set "${1##/}"

if echo -e "?^$1\$?" | ed -s /public_repos >/dev/null 2>&1
then
	echo -e "g|^$1$|d\nw" | ed -s /public_repos
	echo "'$1' is now private!"
elif [ -f "$1/HEAD" ]
then
	echo "Already private!"
else
	clue="$(echo -e "?$1?" | ed -s /public_repos 2>/dev/null)"
	[ "$clue" != '?' ] && echo "Perhaps you wanted: $clue"
	exit 1
fi