-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebdev-scripts-git
More file actions
executable file
·82 lines (72 loc) · 1.56 KB
/
webdev-scripts-git
File metadata and controls
executable file
·82 lines (72 loc) · 1.56 KB
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
81
82
#!/bin/bash
VERSION=1.0
while test $# -gt 0; do
case "$1" in
--start)
shift
if test $# -gt 0; then
startCommit=$1
else
echo "No start commit specified"
exit;
fi
shift
;;
--finish)
shift
if test $# -gt 0; then
finishCommit=$1
else
echo "No finish commit specified"
exit;
fi
shift
;;
-o|--output)
shift
if test $# -gt 0; then
outputFolder=$1
else
echo "No output folder specified"
exit;
fi
;;
-v|--version)
shift
echo "Version: $VERSION"
exit;
;;
esac
done
if [[ -z $startCommit ]]; then
startCommit="HEAD^"
else
startCommit=$startCommit^
fi
if [[ -z $finishCommmit ]]; then
finishCommit=HEAD
fi
if [[ -z $outputFolder ]]; then
outputFolder=PreparedUpload
fi
outputPath=$(pwd)/$outputFolder
echo
echo "usage: git-prepare-upload [--version] [--start <commit>] [--finish <commit>] [-o <outputPath>]"
echo
echo "------------------------- Script Start ------------------------------------"
echo "Copying changed files from range: $startCommit..$finishCommit"
echo "Output folder : $outputPath"
echo "-------------------------------------------------------------"
echo "Prepared Files: "
for i in $(git diff --name-only $startCommit $finishCommit)
do
#Create output folder if it doesn't exist
mkdir -p "$outputFolder/$(dirname $i)"
#Copy all necessary files to this folder
if ! [[ $i == *.gitignore* ]]
then
cp "$i" "$outputFolder/$i"
echo "$i" to "$outputFolder/$i"
fi
done
echo "------------------------- Script Finish ------------------------------------"