-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-fpaste
executable file
·80 lines (71 loc) · 2.31 KB
/
git-fpaste
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Copyright ⓒ 2015 Mattias Bengtsson
#
# git-fpaste is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# git-fpaste is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with git-fpaste. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Mattias Bengtsson <[email protected]>
function am {
if [ $# -lt 1 ]; then
echo "Usage: git fpaste am [git-am options] <url>"
exit 1
else
url="${@: -1}"
am_args="${@:1:$(($#-1))}"
if [[ ! "$url" =~ "/raw" ]]; then
url="${url}/raw/"
fi
curl "${url}" 2>/dev/null | git am $am_args
fi
}
function apply {
if [ $# -lt 1 ]; then
echo "Usage: git fpaste apply [git-apply options] <url>"
exit 1
else
url="${@: -1}"
apply_args="${@:1:$(($#-1))}"
if [[ ! "$url" =~ "/raw" ]]; then
url="${url}/raw/"
fi
curl "${url}" 2>/dev/null | git apply "${apply_args}"
fi
}
function diff {
git diff $@ | fpaste -l diff -n `whoami` --confirm
}
function format-patch {
if [ $# -lt 1 ]; then
echo "Usage: git fpaste format-patch [git-format-patch options]"
exit 1
else
git format-patch --stdout $@ | fpaste -l diff -n `whoami` --confirm
fi
}
cmd="${1}"
shift
case "${cmd}" in
am) am "$@" ;;
apply) apply "$@" ;;
diff) diff "$@" ;;
format-patch) format-patch "$@" ;;
*)
echo "Usage: git fpaste <command> [<args>]"
echo
echo "The available git-fpaste commands are:"
echo " am Apply a mailbox formatted patch series from fpaste"
echo " apply Apply a patch from fpaste"
echo " diff Post changes between commits to fpaste"
echo " format-patch Post a mailbox formatted patch series to fpaste"
exit 1
esac