-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit.sh
51 lines (42 loc) · 1.63 KB
/
commit.sh
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
function git_sparse_checkout {
local url=$1
# directory where the repository will be downloaded, e.g.: ./build/sources
local dir=$2
local prj=$3
local tag=$4
[[ ( -z "$url" ) || ( -z "$dir" ) || ( -z "$prj" ) || ( -z "$tag" ) ]] && \
echo "ERROR: git_sparse_checkout: invalid arguments" && \
return 1
shift; shift; shift; shift
# Note: any remaining arguments after these above are considered as a
# list of files or directories to be downloaded.
cd ..
[ ! -d "cpp-game-web" ] && mkdir cpp-game-web
cd cpp-game-web
git init
git config core.sparseCheckout true
local path="" # local scope
for path in $* ;do
echo "${path}" >> .git/info/sparse-checkout
done
git remote remove origin
git remote add origin https://github.com/schooldev49/Cpp-game
git config remote.origin.pushurl https://github.com/schooldev49/cpp-game-web
git fetch --filter=blob:none origin ${tag}
git checkout ${tag}
git rm -r --cached emsdk
[ -d ".git/modules/emsdk" ] && rm -rf .git/modules/emsdk
[ -d "assets" ] && rm -rf assets
[ -d "test" ] && mv -v test/* ~/cpp-game-web/
[ -d "test" ] && rm -rf test
[ -d "src" ] && rm -rf src
git rm -rf emsdk
git add --all
git commit -m "committed from shell"
git push -f -u origin main
}
url=https://github.com/schooldev49/Cpp-game
dir=$(pwd)/sources
prj=bash-scripts
tag=main
git_sparse_checkout $url $dir $prj $tag "test/*" index.bc index.data index.html index.js index.wasm "emsdk/*"