-
Notifications
You must be signed in to change notification settings - Fork 0
/
auradopt
executable file
·43 lines (38 loc) · 1004 Bytes
/
auradopt
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
#!/bin/bash
# Parse arguments.
while getopts 'hc' argument
do
case $argument in
h)
echo "usage: $0 [options] <package>"
echo 'Set up git remote and branch pointing to AUR package repository.'
echo ' -h show this help text'
echo ' -c include the name of the package in branch and remote name'
exit ;;
c) name= ;;
\?) exit 1 ;;
esac
done
# Compose values.
readonly package="${!OPTIND}"
if [ -z "$package" ]
then
gettext -sd bash 'argument expected'
exit 1
fi
readonly conflicts="aur${name-/*}"
readonly name="aur${name+/${package}}"
# Check conflicting branches.
if [ -n "$(git branch --list "$conflicts")" ]
then
TEXTDOMAIN=git printf "$(gettext "cannot create '%s'"): $(
gettext "A branch named '%s' already exists.")\n" \
"$name" "$conflicts" >&2
exit 1
fi
# Prepare branch.
offremote -n "$name" \
"ssh://[email protected]/${package}.git" \
|| exit $?
# Pull in history.
git fetch "$name" "refs/heads/master:refs/heads/$name"