-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-origin
More file actions
executable file
·47 lines (32 loc) · 762 Bytes
/
add-origin
File metadata and controls
executable file
·47 lines (32 loc) · 762 Bytes
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
set -e -u -o pipefail
: ${ORIGIN:=}
while getopts "o:" OPT; do
case $OPT in
o)
ORIGIN=${OPTARG}
;;
esac
done
shift $((${OPTIND} - 1))
[ -n "${ORIGIN}" ] || {
echo "$(basename $0): origin not specified."
exit 1
}
for _file in "$@"; do
[ -f ${_file} ] || {
echo "$(basename $0): ${_file} does not exist."
exit 1
}
done
_lastfile=""
for _file in "$@"; do
_lastfile=${_file}
echo "$(basename $0): adding ${ORIGIN} to ${_file}."
_tmpfile=$(mktemp)
(echo ${ORIGIN}; cat ${_file}) | sort -f | uniq > ${_tmpfile}
cat ${_tmpfile} > ${_file}
rm ${_tmpfile}
git add ${_file}
done
git commit -m "$(basename $(dirname ${_lastfile})): add ${ORIGIN}."