about summary refs log tree commit diff stats
path: root/core/conf/ports/drivers/git
blob: 654a8c770b7365192be6c2863a17746da4ef2aad (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
# /etc/ports/drivers/git: git driver script for ports(8)
#

if [ $# -ne 1 ]; then
	echo "usage: $0 <file>" >&2
	exit 1
fi

. $1

if [ -z "$URL" ]; then
	echo "URL not set in '$1'" >&2
	exit 2
fi
if [ -z "$NAME" ]; then
	echo "NAME not set in '$1'" >&2
	exit 2
fi
if [ -z "$BRANCH" ]; then
	echo "BRANCH not set in '$1'" >&2
	exit 2
fi

REPOSITORY="$PORTS_DIR/$NAME"
if [ -n "$LOCAL_REPOSITORY" ]; then
	REPOSITORY="$LOCAL_REPOSITORY"
fi

echo "Fetching updates from $URL"
echo "Updating collection $NAME"

cd "$REPOSITORY" 2> "/dev/null"

if [ $? -lt 1 ]; then
	git checkout -q "$BRANCH"
	git fetch -q
	git diff --pretty=format: --name-status "$BRANCH" origin/"$BRANCH" | sed "s/M\t/ Edit /g; s/A\t/ Checkout /g; s/D\t/ Delete /g" | sort
	git clean -q -f
	git reset -q --hard origin/"$BRANCH"
else
	git clone -q -b "$BRANCH" "$URL" "$REPOSITORY"
	ls -1 $REPOSITORY | sed "s/^/ Checkout /"
fi

echo "Finished successfully"